| 1 | #ifndef DOMImplementation_HEADER_GUARD_ |
|---|
| 2 | #define DOMImplementation_HEADER_GUARD_ |
|---|
| 3 | |
|---|
| 4 | /* |
|---|
| 5 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|---|
| 6 | * contributor license agreements. See the NOTICE file distributed with |
|---|
| 7 | * this work for additional information regarding copyright ownership. |
|---|
| 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|---|
| 9 | * (the "License"); you may not use this file except in compliance with |
|---|
| 10 | * the License. You may obtain a copy of the License at |
|---|
| 11 | * |
|---|
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
|---|
| 13 | * |
|---|
| 14 | * Unless required by applicable law or agreed to in writing, software |
|---|
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|---|
| 17 | * See the License for the specific language governing permissions and |
|---|
| 18 | * limitations under the License. |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | /* |
|---|
| 22 | * $Id: DOMImplementation.hpp 568078 2007-08-21 11:43:25Z amassari $ |
|---|
| 23 | */ |
|---|
| 24 | |
|---|
| 25 | #include <xercesc/dom/DOMImplementationLS.hpp> |
|---|
| 26 | #include <xercesc/dom/DOMException.hpp> |
|---|
| 27 | #include <xercesc/dom/DOMRangeException.hpp> |
|---|
| 28 | #include <xercesc/util/PlatformUtils.hpp> |
|---|
| 29 | |
|---|
| 30 | XERCES_CPP_NAMESPACE_BEGIN |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | class DOMDocument; |
|---|
| 34 | class DOMDocumentType; |
|---|
| 35 | |
|---|
| 36 | /** |
|---|
| 37 | * The <code>DOMImplementation</code> interface provides a number of methods |
|---|
| 38 | * for performing operations that are independent of any particular instance |
|---|
| 39 | * of the document object model. |
|---|
| 40 | */ |
|---|
| 41 | |
|---|
| 42 | class CDOM_EXPORT DOMImplementation : public DOMImplementationLS |
|---|
| 43 | { |
|---|
| 44 | protected: |
|---|
| 45 | // ----------------------------------------------------------------------- |
|---|
| 46 | // Hidden constructors |
|---|
| 47 | // ----------------------------------------------------------------------- |
|---|
| 48 | /** @name Hidden constructors */ |
|---|
| 49 | //@{ |
|---|
| 50 | DOMImplementation() {}; // no plain constructor |
|---|
| 51 | //@} |
|---|
| 52 | |
|---|
| 53 | private: |
|---|
| 54 | // ----------------------------------------------------------------------- |
|---|
| 55 | // Unimplemented constructors and operators |
|---|
| 56 | // ----------------------------------------------------------------------- |
|---|
| 57 | /** @name Unimplemented constructors and operators */ |
|---|
| 58 | //@{ |
|---|
| 59 | DOMImplementation(const DOMImplementation &); // no copy construtor. |
|---|
| 60 | DOMImplementation & operator = (const DOMImplementation &); // No Assignment |
|---|
| 61 | //@} |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | public: |
|---|
| 65 | // ----------------------------------------------------------------------- |
|---|
| 66 | // All constructors are hidden, just the destructor is available |
|---|
| 67 | // ----------------------------------------------------------------------- |
|---|
| 68 | /** @name Destructor */ |
|---|
| 69 | //@{ |
|---|
| 70 | /** |
|---|
| 71 | * Destructor |
|---|
| 72 | * |
|---|
| 73 | */ |
|---|
| 74 | virtual ~DOMImplementation() {}; |
|---|
| 75 | //@} |
|---|
| 76 | |
|---|
| 77 | // ----------------------------------------------------------------------- |
|---|
| 78 | // Virtual DOMImplementation interface |
|---|
| 79 | // ----------------------------------------------------------------------- |
|---|
| 80 | /** @name Functions introduced in DOM Level 1 */ |
|---|
| 81 | //@{ |
|---|
| 82 | /** |
|---|
| 83 | * Test if the DOM implementation implements a specific feature. |
|---|
| 84 | * @param feature The name of the feature to test (case-insensitive). The |
|---|
| 85 | * values used by DOM features are defined throughout the DOM Level 2 |
|---|
| 86 | * specifications and listed in the section. The name must be an XML |
|---|
| 87 | * name. To avoid possible conflicts, as a convention, names referring |
|---|
| 88 | * to features defined outside the DOM specification should be made |
|---|
| 89 | * unique. |
|---|
| 90 | * @param version This is the version number of the feature to test. In |
|---|
| 91 | * Level 2, the string can be either "2.0" or "1.0". If the version is |
|---|
| 92 | * not specified, supporting any version of the feature causes the |
|---|
| 93 | * method to return <code>true</code>. |
|---|
| 94 | * @return <code>true</code> if the feature is implemented in the |
|---|
| 95 | * specified version, <code>false</code> otherwise. |
|---|
| 96 | * @since DOM Level 1 |
|---|
| 97 | */ |
|---|
| 98 | virtual bool hasFeature(const XMLCh *feature, const XMLCh *version) const = 0; |
|---|
| 99 | //@} |
|---|
| 100 | |
|---|
| 101 | // ----------------------------------------------------------------------- |
|---|
| 102 | // Functions introduced in DOM Level 2 |
|---|
| 103 | // ----------------------------------------------------------------------- |
|---|
| 104 | /** @name Functions introduced in DOM Level 2 */ |
|---|
| 105 | //@{ |
|---|
| 106 | /** |
|---|
| 107 | * Creates an empty <code>DOMDocumentType</code> node. Entity declarations |
|---|
| 108 | * and notations are not made available. Entity reference expansions and |
|---|
| 109 | * default attribute additions do not occur. It is expected that a |
|---|
| 110 | * future version of the DOM will provide a way for populating a |
|---|
| 111 | * <code>DOMDocumentType</code>. |
|---|
| 112 | * @param qualifiedName The qualified name of the document type to be |
|---|
| 113 | * created. |
|---|
| 114 | * @param publicId The external subset public identifier. |
|---|
| 115 | * @param systemId The external subset system identifier. |
|---|
| 116 | * @return A new <code>DOMDocumentType</code> node with |
|---|
| 117 | * <code>ownerDocument</code> set to <code>null</code>. |
|---|
| 118 | * @exception DOMException |
|---|
| 119 | * INVALID_CHARACTER_ERR: Raised if the specified qualified name |
|---|
| 120 | * contains an illegal character. |
|---|
| 121 | * <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is |
|---|
| 122 | * malformed. |
|---|
| 123 | * <br>NOT_SUPPORTED_ERR: May be raised by DOM implementations which do |
|---|
| 124 | * not support the <code>"XML"</code> feature, if they choose not to |
|---|
| 125 | * support this method. Other features introduced in the future, by |
|---|
| 126 | * the DOM WG or in extensions defined by other groups, may also |
|---|
| 127 | * demand support for this method; please consult the definition of |
|---|
| 128 | * the feature to see if it requires this method. |
|---|
| 129 | * @since DOM Level 2 |
|---|
| 130 | */ |
|---|
| 131 | virtual DOMDocumentType *createDocumentType(const XMLCh *qualifiedName, |
|---|
| 132 | const XMLCh *publicId, |
|---|
| 133 | const XMLCh *systemId) = 0; |
|---|
| 134 | |
|---|
| 135 | /** |
|---|
| 136 | * Creates a DOMDocument object of the specified type with its document |
|---|
| 137 | * element. |
|---|
| 138 | * @param namespaceURI The namespace URI of the document element to |
|---|
| 139 | * create. |
|---|
| 140 | * @param qualifiedName The qualified name of the document element to be |
|---|
| 141 | * created. |
|---|
| 142 | * @param doctype The type of document to be created or <code>null</code>. |
|---|
| 143 | * When <code>doctype</code> is not <code>null</code>, its |
|---|
| 144 | * <code>ownerDocument</code> attribute is set to the document |
|---|
| 145 | * being created. |
|---|
| 146 | * @param manager Pointer to the memory manager to be used to |
|---|
| 147 | * allocate objects. |
|---|
| 148 | * @return A new <code>DOMDocument</code> object. |
|---|
| 149 | * @exception DOMException |
|---|
| 150 | * INVALID_CHARACTER_ERR: Raised if the specified qualified name |
|---|
| 151 | * contains an illegal character. |
|---|
| 152 | * <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is |
|---|
| 153 | * malformed, if the <code>qualifiedName</code> has a prefix and the |
|---|
| 154 | * <code>namespaceURI</code> is <code>null</code>, or if the |
|---|
| 155 | * <code>qualifiedName</code> has a prefix that is "xml" and the |
|---|
| 156 | * <code>namespaceURI</code> is different from " |
|---|
| 157 | * http://www.w3.org/XML/1998/namespace" , or if the DOM |
|---|
| 158 | * implementation does not support the <code>"XML"</code> feature but |
|---|
| 159 | * a non-null namespace URI was provided, since namespaces were |
|---|
| 160 | * defined by XML. |
|---|
| 161 | * <br>WRONG_DOCUMENT_ERR: Raised if <code>doctype</code> has already |
|---|
| 162 | * been used with a different document or was created from a different |
|---|
| 163 | * implementation. |
|---|
| 164 | * <br>NOT_SUPPORTED_ERR: May be raised by DOM implementations which do |
|---|
| 165 | * not support the "XML" feature, if they choose not to support this |
|---|
| 166 | * method. Other features introduced in the future, by the DOM WG or |
|---|
| 167 | * in extensions defined by other groups, may also demand support for |
|---|
| 168 | * this method; please consult the definition of the feature to see if |
|---|
| 169 | * it requires this method. |
|---|
| 170 | * @since DOM Level 2 |
|---|
| 171 | */ |
|---|
| 172 | |
|---|
| 173 | virtual DOMDocument *createDocument(const XMLCh *namespaceURI, |
|---|
| 174 | const XMLCh *qualifiedName, |
|---|
| 175 | DOMDocumentType *doctype, |
|---|
| 176 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0; |
|---|
| 177 | |
|---|
| 178 | //@} |
|---|
| 179 | // ----------------------------------------------------------------------- |
|---|
| 180 | // Functions introduced in DOM Level 3 |
|---|
| 181 | // ----------------------------------------------------------------------- |
|---|
| 182 | /** @name Functions introduced in DOM Level 3 */ |
|---|
| 183 | //@{ |
|---|
| 184 | /** |
|---|
| 185 | * This method makes available a <code>DOMImplementation</code>'s |
|---|
| 186 | * specialized interface (see ). |
|---|
| 187 | * |
|---|
| 188 | * <p><b>"Experimental - subject to change"</b></p> |
|---|
| 189 | * |
|---|
| 190 | * @param feature The name of the feature requested (case-insensitive). |
|---|
| 191 | * @return Returns an alternate <code>DOMImplementation</code> which |
|---|
| 192 | * implements the specialized APIs of the specified feature, if any, |
|---|
| 193 | * or <code>null</code> if there is no alternate |
|---|
| 194 | * <code>DOMImplementation</code> object which implements interfaces |
|---|
| 195 | * associated with that feature. Any alternate |
|---|
| 196 | * <code>DOMImplementation</code> returned by this method must |
|---|
| 197 | * delegate to the primary core <code>DOMImplementation</code> and not |
|---|
| 198 | * return results inconsistent with the primary |
|---|
| 199 | * <code>DOMImplementation</code> |
|---|
| 200 | * @since DOM Level 3 |
|---|
| 201 | */ |
|---|
| 202 | virtual DOMImplementation* getInterface(const XMLCh* feature) = 0; |
|---|
| 203 | |
|---|
| 204 | //@} |
|---|
| 205 | |
|---|
| 206 | // ----------------------------------------------------------------------- |
|---|
| 207 | // Non-standard extension |
|---|
| 208 | // ----------------------------------------------------------------------- |
|---|
| 209 | /** @name Non-standard extension */ |
|---|
| 210 | //@{ |
|---|
| 211 | /** |
|---|
| 212 | * Non-standard extension |
|---|
| 213 | * |
|---|
| 214 | * Create a completely empty document that has neither a root element or a doctype node. |
|---|
| 215 | */ |
|---|
| 216 | virtual DOMDocument *createDocument(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0; |
|---|
| 217 | |
|---|
| 218 | /** |
|---|
| 219 | * Non-standard extension |
|---|
| 220 | * |
|---|
| 221 | * Factory method for getting a DOMImplementation object. |
|---|
| 222 | * The DOM implementation retains ownership of the returned object. |
|---|
| 223 | * Application code should NOT delete it. |
|---|
| 224 | */ |
|---|
| 225 | static DOMImplementation *getImplementation(); |
|---|
| 226 | |
|---|
| 227 | /** |
|---|
| 228 | * Non-standard extension |
|---|
| 229 | * |
|---|
| 230 | * Load the default error text message for DOMException. |
|---|
| 231 | * @param msgToLoad The DOM ExceptionCode id to be processed |
|---|
| 232 | * @param toFill The buffer that will hold the output on return. The |
|---|
| 233 | * size of this buffer should at least be 'maxChars + 1'. |
|---|
| 234 | * @param maxChars The maximum number of output characters that can be |
|---|
| 235 | * accepted. If the result will not fit, it is an error. |
|---|
| 236 | * @return <code>true</code> if the message is successfully loaded |
|---|
| 237 | */ |
|---|
| 238 | static bool loadDOMExceptionMsg |
|---|
| 239 | ( |
|---|
| 240 | const DOMException::ExceptionCode msgToLoad |
|---|
| 241 | , XMLCh* const toFill |
|---|
| 242 | , const unsigned int maxChars |
|---|
| 243 | ); |
|---|
| 244 | |
|---|
| 245 | /** |
|---|
| 246 | * Non-standard extension |
|---|
| 247 | * |
|---|
| 248 | * Load the default error text message for DOMRangeException. |
|---|
| 249 | * @param msgToLoad The DOM RangeExceptionCode id to be processed |
|---|
| 250 | * @param toFill The buffer that will hold the output on return. The |
|---|
| 251 | * size of this buffer should at least be 'maxChars + 1'. |
|---|
| 252 | * @param maxChars The maximum number of output characters that can be |
|---|
| 253 | * accepted. If the result will not fit, it is an error. |
|---|
| 254 | * @return <code>true</code> if the message is successfully loaded |
|---|
| 255 | */ |
|---|
| 256 | static bool loadDOMExceptionMsg |
|---|
| 257 | ( |
|---|
| 258 | const DOMRangeException::RangeExceptionCode msgToLoad |
|---|
| 259 | , XMLCh* const toFill |
|---|
| 260 | , const unsigned int maxChars |
|---|
| 261 | ); |
|---|
| 262 | //@} |
|---|
| 263 | |
|---|
| 264 | }; |
|---|
| 265 | |
|---|
| 266 | XERCES_CPP_NAMESPACE_END |
|---|
| 267 | |
|---|
| 268 | #endif |
|---|