|
|
|||
File indexing completed on 2025-12-16 10:34:14
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_INPUTSOURCE_HPP) 0023 #define XERCESC_INCLUDE_GUARD_INPUTSOURCE_HPP 0024 0025 #include <xercesc/util/PlatformUtils.hpp> 0026 0027 XERCES_CPP_NAMESPACE_BEGIN 0028 0029 class BinInputStream; 0030 0031 0032 /** 0033 * A single input source for an XML entity. 0034 * 0035 * <p>This class encapsulates information about an input source in a 0036 * single object, which may include a public identifier or a system 0037 * identifier</p> 0038 * 0039 * <p>There are two places that the application will deliver this input 0040 * source to the parser: as the argument to the Parser::parse method, or as 0041 * the return value of the EntityResolver::resolveEntity method.</p> 0042 * 0043 * <p>InputSource is never used directly, but is the base class for a number 0044 * of derived classes for particular types of input sources. Derivatives are 0045 * provided (in the framework/ directory) for URL input sources, memory buffer 0046 * input sources, and so on.</p> 0047 * 0048 * <p>When it is time to parse the input described by an input source, it 0049 * will be asked to create a binary stream for that source. That stream will 0050 * be used to input the data of the source. The derived class provides the 0051 * implementation of the makeStream() method, and provides a type of stream 0052 * of the correct type for the input source it represents. 0053 * 0054 * <p>An InputSource object belongs to the application: the parser never 0055 * modifies them in any way. They are always passed by const reference so 0056 * the parser will make a copy of any input sources that it must keep 0057 * around beyond the call.</p> 0058 * 0059 * @see Parser#parse 0060 * @see EntityResolver#resolveEntity 0061 */ 0062 class SAX_EXPORT InputSource : public XMemory 0063 { 0064 public: 0065 // ----------------------------------------------------------------------- 0066 // All constructors are hidden, just the destructor is available 0067 // ----------------------------------------------------------------------- 0068 /** @name Destructor */ 0069 //@{ 0070 /** 0071 * Destructor 0072 * 0073 */ 0074 virtual ~InputSource(); 0075 //@} 0076 0077 0078 // ----------------------------------------------------------------------- 0079 /** @name Virtual input source interface */ 0080 //@{ 0081 /** 0082 * Makes the byte stream for this input source. 0083 * 0084 * <p>The derived class must create and return a binary input stream of an 0085 * appropriate type for its kind of data source. The returned stream must 0086 * be dynamically allocated and becomes the parser's property. 0087 * </p> 0088 * 0089 * @see BinInputStream 0090 */ 0091 virtual BinInputStream* makeStream() const = 0; 0092 0093 //@} 0094 0095 0096 // ----------------------------------------------------------------------- 0097 /** @name Getter methods */ 0098 //@{ 0099 /** 0100 * An input source can be set to force the parser to assume a particular 0101 * encoding for the data that input source represents, via the setEncoding() 0102 * method. This method returns name of the encoding that is to be forced. 0103 * If the encoding has never been forced, it returns a null pointer. 0104 * 0105 * @return The forced encoding, or null if none was supplied. 0106 * @see #setEncoding 0107 */ 0108 virtual const XMLCh* getEncoding() const; 0109 0110 0111 /** 0112 * Get the public identifier for this input source. 0113 * 0114 * @return The public identifier, or null if none was supplied. 0115 * @see #setPublicId 0116 */ 0117 virtual const XMLCh* getPublicId() const; 0118 0119 0120 /** 0121 * Get the system identifier for this input source. 0122 * 0123 * <p>If the system ID is a URL, it will be fully resolved.</p> 0124 * 0125 * @return The system identifier. 0126 * @see #setSystemId 0127 */ 0128 virtual const XMLCh* getSystemId() const; 0129 0130 /** 0131 * Get the flag that indicates if the parser should issue fatal error if this input source 0132 * is not found. 0133 * 0134 * @return True if the parser should issue fatal error if this input source is not found. 0135 * False if the parser issue warning message instead. 0136 * @see #setIssueFatalErrorIfNotFound 0137 */ 0138 virtual bool getIssueFatalErrorIfNotFound() const; 0139 0140 MemoryManager* getMemoryManager() const; 0141 0142 //@} 0143 0144 0145 // ----------------------------------------------------------------------- 0146 /** @name Setter methods */ 0147 //@{ 0148 0149 /** 0150 * Set the encoding which will be required for use with the XML text read 0151 * via a stream opened by this input source. 0152 * 0153 * <p>This is usually not set, allowing the encoding to be sensed in the 0154 * usual XML way. However, in some cases, the encoding in the file is known 0155 * to be incorrect because of intermediate transcoding, for instance 0156 * encapsulation within a MIME document. 0157 * 0158 * @param encodingStr The name of the encoding to force. 0159 */ 0160 virtual void setEncoding(const XMLCh* const encodingStr); 0161 0162 0163 /** 0164 * Set the public identifier for this input source. 0165 * 0166 * <p>The public identifier is always optional: if the application writer 0167 * includes one, it will be provided as part of the location information.</p> 0168 * 0169 * @param publicId The public identifier as a string. 0170 * @see Locator#getPublicId 0171 * @see SAXParseException#getPublicId 0172 * @see #getPublicId 0173 */ 0174 virtual void setPublicId(const XMLCh* const publicId); 0175 0176 /** 0177 * Set the system identifier for this input source. 0178 * 0179 * <p>Set the system identifier for this input source. 0180 * 0181 * </p>The system id is always required. The public id may be used to map 0182 * to another system id, but the system id must always be present as a fall 0183 * back. 0184 * 0185 * <p>If the system ID is a URL, it must be fully resolved.</p> 0186 * 0187 * @param systemId The system identifier as a string. 0188 * @see #getSystemId 0189 * @see Locator#getSystemId 0190 * @see SAXParseException#getSystemId 0191 */ 0192 virtual void setSystemId(const XMLCh* const systemId); 0193 0194 /** 0195 * Indicates if the parser should issue fatal error if this input source 0196 * is not found. If set to false, the parser issue warning message instead. 0197 * 0198 * @param flag True if the parser should issue fatal error if this input source is not found. 0199 * If set to false, the parser issue warning message instead. (Default: true) 0200 * 0201 * @see #getIssueFatalErrorIfNotFound 0202 */ 0203 virtual void setIssueFatalErrorIfNotFound(const bool flag); 0204 0205 //@} 0206 0207 0208 protected : 0209 // ----------------------------------------------------------------------- 0210 // Hidden constructors 0211 // ----------------------------------------------------------------------- 0212 /** @name Constructors and Destructor */ 0213 //@{ 0214 /** Default constructor */ 0215 InputSource(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0216 0217 /** Constructor with a system identifier as XMLCh type. 0218 * @param systemId The system identifier (URI). 0219 * @param manager Pointer to the memory manager to be used to 0220 * allocate objects. 0221 */ 0222 InputSource(const XMLCh* const systemId, 0223 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0224 0225 /** Constructor with a system and public identifiers 0226 * @param systemId The system identifier (URI). 0227 * @param publicId The public identifier as in the entity definition. 0228 * @param manager Pointer to the memory manager to be used to 0229 * allocate objects. 0230 */ 0231 InputSource 0232 ( 0233 const XMLCh* const systemId 0234 , const XMLCh* const publicId 0235 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0236 ); 0237 0238 /** Constructor witha system identifier as string 0239 * @param systemId The system identifier (URI). 0240 * @param manager Pointer to the memory manager to be used to 0241 * allocate objects. 0242 */ 0243 InputSource(const char* const systemId, 0244 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0245 0246 /** Constructor witha system and public identifiers. Both as string 0247 * @param systemId The system identifier (URI). 0248 * @param publicId The public identifier as in the entity definition. 0249 * @param manager Pointer to the memory manager to be used to 0250 * allocate objects. 0251 */ 0252 InputSource 0253 ( 0254 const char* const systemId 0255 , const char* const publicId 0256 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0257 ); 0258 0259 //@} 0260 0261 0262 0263 0264 0265 private: 0266 // ----------------------------------------------------------------------- 0267 // Unimplemented constructors and operators 0268 // ----------------------------------------------------------------------- 0269 InputSource(const InputSource&); 0270 InputSource& operator=(const InputSource&); 0271 0272 0273 // ----------------------------------------------------------------------- 0274 // Private data members 0275 // 0276 // fEncoding 0277 // This is the encoding to use. Usually this is null, which means 0278 // to use the information found in the file itself. But, if set, 0279 // this encoding will be used without question. 0280 // 0281 // fPublicId 0282 // This is the optional public id for the input source. It can be 0283 // null if none is desired. 0284 // 0285 // fSystemId 0286 // This is the system id for the input source. This is what is 0287 // actually used to open the source. 0288 // 0289 // fFatalErrorIfNotFound 0290 // ----------------------------------------------------------------------- 0291 MemoryManager* const fMemoryManager; 0292 XMLCh* fEncoding; 0293 XMLCh* fPublicId; 0294 XMLCh* fSystemId; 0295 bool fFatalErrorIfNotFound; 0296 }; 0297 0298 0299 // --------------------------------------------------------------------------- 0300 // InputSource: Getter methods 0301 // --------------------------------------------------------------------------- 0302 inline const XMLCh* InputSource::getEncoding() const 0303 { 0304 return fEncoding; 0305 } 0306 0307 inline const XMLCh* InputSource::getPublicId() const 0308 { 0309 return fPublicId; 0310 } 0311 0312 inline const XMLCh* InputSource::getSystemId() const 0313 { 0314 return fSystemId; 0315 } 0316 0317 inline bool InputSource::getIssueFatalErrorIfNotFound() const 0318 { 0319 return fFatalErrorIfNotFound; 0320 } 0321 0322 inline MemoryManager* InputSource::getMemoryManager() const 0323 { 0324 return fMemoryManager; 0325 } 0326 0327 // --------------------------------------------------------------------------- 0328 // InputSource: Setter methods 0329 // --------------------------------------------------------------------------- 0330 inline void InputSource::setIssueFatalErrorIfNotFound(const bool flag) 0331 { 0332 fFatalErrorIfNotFound = flag; 0333 } 0334 0335 XERCES_CPP_NAMESPACE_END 0336 0337 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|