|
||||
File indexing completed on 2025-01-18 10:14:52
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one or more 0003 * contributor license agreements. See the NOTICE file distributed with 0004 * this work for additional information regarding copyright ownership. 0005 * The ASF licenses this file to You under the Apache License, Version 2.0 0006 * (the "License"); you may not use this file except in compliance with 0007 * the License. You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 */ 0017 0018 /* 0019 * $Id$ 0020 */ 0021 0022 #if !defined(XERCESC_INCLUDE_GUARD_WRAPPER4INPUTSOURCE_HPP) 0023 #define XERCESC_INCLUDE_GUARD_WRAPPER4INPUTSOURCE_HPP 0024 0025 #include <xercesc/dom/DOMLSInput.hpp> 0026 #include <xercesc/util/PlatformUtils.hpp> 0027 0028 XERCES_CPP_NAMESPACE_BEGIN 0029 0030 class InputSource; 0031 0032 0033 /** 0034 * Wrap a SAX InputSource object and make it behave like DOMLSInput. 0035 */ 0036 class XMLPARSER_EXPORT Wrapper4InputSource: public DOMLSInput 0037 { 0038 public: 0039 /** @name Constructors and Destructor */ 0040 //@{ 0041 0042 /** 0043 * Constructor 0044 * 0045 * Wrap a SAX InputSource and make it behave like a DOMLSInput. 0046 * By default, the wrapper will adopt the SAX InputSource that is wrapped. 0047 * 0048 * @param inputSource The SAX InputSource to be wrapped 0049 * @param adoptFlag Indicates if the wrapper should adopt the wrapped 0050 * SAX InputSource. Default is true. 0051 * @param manager The MemoryManager to use to allocate objects 0052 */ 0053 Wrapper4InputSource(InputSource* const inputSource 0054 , const bool adoptFlag = true 0055 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0056 0057 /** 0058 * Destructor 0059 * 0060 */ 0061 virtual ~Wrapper4InputSource(); 0062 //@} 0063 0064 0065 // ----------------------------------------------------------------------- 0066 /** @name Virtual input source interface */ 0067 //@{ 0068 /** 0069 * This wrapper doesn't support string data 0070 * 0071 */ 0072 virtual const XMLCh* getStringData() const; 0073 0074 /** 0075 * Makes the byte stream for this input source. 0076 * 0077 * <p>The function will call the makeStream of the wrapped input source. 0078 * The returned stream becomes the parser's property.</p> 0079 * 0080 * @see InputSource 0081 */ 0082 virtual InputSource* getByteStream() const; 0083 //@} 0084 0085 // ----------------------------------------------------------------------- 0086 /** @name Getter methods */ 0087 //@{ 0088 /** 0089 * An input source can be set to force the parser to assume a particular 0090 * encoding for the data that input source represents, via the setEncoding() 0091 * method. This method will delegate to the wrapped input source to return 0092 * name of the encoding that is to be forced. If the encoding has never 0093 * been forced, it returns a null pointer. 0094 * 0095 * @return The forced encoding, or null if none was supplied. 0096 * @see #setEncoding 0097 */ 0098 virtual const XMLCh* getEncoding() const; 0099 0100 0101 /** 0102 * Get the public identifier for this input source. Delegated to the 0103 * wrapped input source object. 0104 * 0105 * @return The public identifier, or null if none was supplied. 0106 * @see #setPublicId 0107 */ 0108 const XMLCh* getPublicId() const; 0109 0110 0111 /** 0112 * Get the system identifier for this input source. Delegated to the 0113 * wrapped input source object. 0114 * 0115 * <p>If the system ID is a URL, it will be fully resolved.</p> 0116 * 0117 * @return The system identifier. 0118 * @see #setSystemId 0119 */ 0120 const XMLCh* getSystemId() const; 0121 0122 /** 0123 * Get the base URI to be used for resolving relative URIs to absolute 0124 * URIs. If the baseURI is itself a relative URI, the behavior is 0125 * implementation dependent. Delegated to the wrapped intput source 0126 * object. 0127 * 0128 * @return The base URI. 0129 * @see #setBaseURI 0130 * @since DOM Level 3 0131 */ 0132 const XMLCh* getBaseURI() const; 0133 0134 /** 0135 * Get the flag that indicates if the parser should issue fatal error if this input source 0136 * is not found. Delegated to the wrapped input source object. 0137 * 0138 * @return True if the parser should issue fatal error if this input source is not found. 0139 * False if the parser issue warning message instead. 0140 * @see #setIssueFatalErrorIfNotFound 0141 */ 0142 bool getIssueFatalErrorIfNotFound() const; 0143 0144 //@} 0145 0146 0147 // ----------------------------------------------------------------------- 0148 /** @name Setter methods */ 0149 //@{ 0150 /** 0151 * This wrapper only exposes the given InputSource, no setting allowed 0152 * 0153 */ 0154 virtual void setStringData(const XMLCh* data); 0155 0156 /** 0157 * This wrapper only exposes the given InputSource, no setting allowed 0158 * 0159 */ 0160 virtual void setByteStream(InputSource* stream); 0161 0162 /** 0163 * Set the encoding which will be required for use with the XML text read 0164 * via a stream opened by this input source. This will update the wrapped 0165 * input source object. 0166 * 0167 * <p>This is usually not set, allowing the encoding to be sensed in the 0168 * usual XML way. However, in some cases, the encoding in the file is known 0169 * to be incorrect because of intermediate transcoding, for instance 0170 * encapsulation within a MIME document. 0171 * 0172 * @param encodingStr The name of the encoding to force. 0173 */ 0174 void setEncoding(const XMLCh* const encodingStr); 0175 0176 0177 /** 0178 * Set the public identifier for this input source. This will update the 0179 * wrapped input source object. 0180 * 0181 * <p>The public identifier is always optional: if the application writer 0182 * includes one, it will be provided as part of the location information.</p> 0183 * 0184 * @param publicId The public identifier as a string. 0185 * @see Locator#getPublicId 0186 * @see SAXParseException#getPublicId 0187 * @see #getPublicId 0188 */ 0189 void setPublicId(const XMLCh* const publicId); 0190 0191 /** 0192 * Set the system identifier for this input source. This will update the 0193 * wrapped input source object. 0194 * 0195 * <p>The system id is always required. The public id may be used to map 0196 * to another system id, but the system id must always be present as a fall 0197 * back.</p> 0198 * 0199 * <p>If the system ID is a URL, it must be fully resolved.</p> 0200 * 0201 * @param systemId The system identifier as a string. 0202 * @see #getSystemId 0203 * @see Locator#getSystemId 0204 * @see SAXParseException#getSystemId 0205 */ 0206 void setSystemId(const XMLCh* const systemId); 0207 0208 /** 0209 * Set the base URI to be used for resolving relative URIs to absolute 0210 * URIs. If the baseURI is itself a relative URI, the behavior is 0211 * implementation dependent. This will update the wrapped input source 0212 * object. 0213 * 0214 * @param baseURI The base URI. 0215 * @see #getBaseURI 0216 * @since DOM Level 3 0217 */ 0218 void setBaseURI(const XMLCh* const baseURI); 0219 0220 /** 0221 * Indicates if the parser should issue fatal error if this input source 0222 * is not found. If set to false, the parser issue warning message 0223 * instead. This will update the wrapped input source object. 0224 * 0225 * @param flag True if the parser should issue fatal error if this input 0226 * source is not found. 0227 * If set to false, the parser issue warning message instead. 0228 * (Default: true) 0229 * 0230 * @see #getIssueFatalErrorIfNotFound 0231 */ 0232 void setIssueFatalErrorIfNotFound(bool flag); 0233 0234 /** 0235 * Called to indicate that this DOMInputSource is no longer in use 0236 * and that the implementation may relinquish any resources associated with it. 0237 * 0238 * Access to a released object will lead to unexpected result. 0239 */ 0240 void release(); 0241 0242 //@} 0243 0244 0245 private: 0246 // ----------------------------------------------------------------------- 0247 // Unimplemented constructors and operators 0248 // ----------------------------------------------------------------------- 0249 Wrapper4InputSource(const Wrapper4InputSource&); 0250 Wrapper4InputSource& operator=(const Wrapper4InputSource&); 0251 0252 // ----------------------------------------------------------------------- 0253 // Private data members 0254 // ----------------------------------------------------------------------- 0255 bool fAdoptInputSource; 0256 InputSource* fInputSource; 0257 }; 0258 0259 0260 // --------------------------------------------------------------------------- 0261 // Wrapper4InputSource: Getter methods 0262 // --------------------------------------------------------------------------- 0263 inline const XMLCh* Wrapper4InputSource::getBaseURI() const 0264 { 0265 return 0; // REVISIT - should we return an empty string? 0266 } 0267 0268 inline const XMLCh* Wrapper4InputSource::getStringData() const 0269 { 0270 return 0; 0271 } 0272 0273 // --------------------------------------------------------------------------- 0274 // Wrapper4InputSource: Setter methods 0275 // --------------------------------------------------------------------------- 0276 inline void Wrapper4InputSource::setBaseURI(const XMLCh* const) 0277 { 0278 } 0279 0280 inline void Wrapper4InputSource::setStringData(const XMLCh*) 0281 { 0282 } 0283 0284 inline void Wrapper4InputSource::setByteStream(InputSource*) 0285 { 0286 } 0287 0288 XERCES_CPP_NAMESPACE_END 0289 0290 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |