File indexing completed on 2025-01-18 10:14:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #if !defined(XERCESC_INCLUDE_GUARD_READERMGR_HPP)
0023 #define XERCESC_INCLUDE_GUARD_READERMGR_HPP
0024
0025 #include <xercesc/internal/XMLReader.hpp>
0026 #include <xercesc/util/PlatformUtils.hpp>
0027 #include <xercesc/util/RefStackOf.hpp>
0028 #include <xercesc/sax/Locator.hpp>
0029 #include <xercesc/framework/XMLBuffer.hpp>
0030
0031 XERCES_CPP_NAMESPACE_BEGIN
0032
0033 class XMLEntityDecl;
0034 class XMLEntityHandler;
0035 class XMLDocumentHandler;
0036 class XMLScanner;
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048 class XMLPARSER_EXPORT ReaderMgr : public XMemory
0049 , public Locator
0050 {
0051 public :
0052
0053
0054
0055 struct LastExtEntityInfo : public XMemory
0056 {
0057 const XMLCh* systemId;
0058 const XMLCh* publicId;
0059 XMLFileLoc lineNumber;
0060 XMLFileLoc colNumber;
0061 };
0062
0063
0064
0065
0066
0067 ReaderMgr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0068 ~ReaderMgr();
0069
0070
0071
0072
0073
0074
0075
0076
0077 bool atEOF() const;
0078 bool getName(XMLBuffer& toFill);
0079 bool getQName(XMLBuffer& toFill, int* colonPosition);
0080 bool getNameToken(XMLBuffer& toFill);
0081 XMLCh getNextChar();
0082 bool getNextCharIfNot(const XMLCh chNotToGet, XMLCh& chGotten);
0083 void movePlainContentChars(XMLBuffer &dest);
0084 void getSpaces(XMLBuffer& toFill);
0085 void getUpToCharOrWS(XMLBuffer& toFill, const XMLCh toCheck);
0086 bool isEmpty() const;
0087 bool lookingAtChar(const XMLCh toCheck);
0088 bool lookingAtSpace();
0089 XMLCh peekNextChar();
0090 bool skipIfQuote(XMLCh& chGotten);
0091 void skipPastChar(const XMLCh toSkip);
0092 void skipPastSpaces(bool& skippedSomething, bool inDecl = false);
0093 void skipPastSpaces();
0094 void skipToChar(const XMLCh toSkipTo);
0095 bool skippedChar(const XMLCh toSkip);
0096 bool skippedSpace();
0097 bool skippedString(const XMLCh* const toSkip);
0098 bool skippedStringLong(const XMLCh* const toSkip);
0099 void skipQuotedString(const XMLCh quoteCh);
0100 XMLCh skipUntilIn(const XMLCh* const listToSkip);
0101 XMLCh skipUntilInOrWS(const XMLCh* const listToSkip);
0102 bool peekString(const XMLCh* const toPeek);
0103
0104
0105
0106
0107
0108 void cleanStackBackTo(const XMLSize_t readerNum);
0109 XMLReader* createReader
0110 (
0111 const InputSource& src
0112 , const bool xmlDecl
0113 , const XMLReader::RefFrom refFrom
0114 , const XMLReader::Types type
0115 , const XMLReader::Sources source
0116 , const bool calcSrsOfs = true
0117 , XMLSize_t lowWaterMark = 100
0118 );
0119 XMLReader* createReader
0120 (
0121 const XMLCh* const sysId
0122 , const XMLCh* const pubId
0123 , const bool xmlDecl
0124 , const XMLReader::RefFrom refFrom
0125 , const XMLReader::Types type
0126 , const XMLReader::Sources source
0127 , InputSource*& srcToFill
0128 , const bool calcSrcOfs = true
0129 , XMLSize_t lowWaterMark = 100
0130 , const bool disableDefaultEntityResolution = false
0131 );
0132 XMLReader* createReader
0133 (
0134 const XMLCh* const baseURI
0135 , const XMLCh* const sysId
0136 , const XMLCh* const pubId
0137 , const bool xmlDecl
0138 , const XMLReader::RefFrom refFrom
0139 , const XMLReader::Types type
0140 , const XMLReader::Sources source
0141 , InputSource*& srcToFill
0142 , const bool calcSrcOfs = true
0143 , XMLSize_t lowWaterMark = 100
0144 , const bool disableDefaultEntityResolution = false
0145 );
0146 XMLReader* createIntEntReader
0147 (
0148 const XMLCh* const sysId
0149 , const XMLReader::RefFrom refFrom
0150 , const XMLReader::Types type
0151 , const XMLCh* const dataBuf
0152 , const XMLSize_t dataLen
0153 , const bool copyBuf
0154 , const bool calcSrcOfs = true
0155 , XMLSize_t lowWaterMark = 100
0156 );
0157 bool isScanningPERefOutOfLiteral() const;
0158 bool pushReader
0159 (
0160 XMLReader* const reader
0161 , XMLEntityDecl* const entity
0162 );
0163 bool pushReaderAdoptEntity
0164 (
0165 XMLReader* const reader
0166 , XMLEntityDecl* const entity
0167 , const bool adoptEntity = true
0168 );
0169 void reset();
0170
0171
0172
0173
0174
0175 const XMLCh* getCurrentEncodingStr() const;
0176 const XMLEntityDecl* getCurrentEntity() const;
0177 XMLEntityDecl* getCurrentEntity();
0178 const XMLReader* getCurrentReader() const;
0179 XMLReader* getCurrentReader();
0180 XMLSize_t getCurrentReaderNum() const;
0181 XMLSize_t getReaderDepth() const;
0182 void getLastExtEntityInfo(LastExtEntityInfo& lastInfo) const;
0183 XMLFilePos getSrcOffset() const;
0184 bool getThrowEOE() const;
0185
0186
0187
0188
0189
0190 void setEntityHandler(XMLEntityHandler* const newHandler);
0191 void setThrowEOE(const bool newValue);
0192 void setXMLVersion(const XMLReader::XMLVersion version);
0193 void setStandardUriConformant(const bool newValue);
0194
0195
0196
0197
0198 virtual const XMLCh* getPublicId() const;
0199 virtual const XMLCh* getSystemId() const;
0200 virtual XMLFileLoc getLineNumber() const;
0201 virtual XMLFileLoc getColumnNumber() const;
0202
0203
0204 private :
0205
0206
0207
0208 const XMLReader* getLastExtEntity(const XMLEntityDecl*& itsEntity) const;
0209 bool popReader();
0210
0211
0212
0213
0214 ReaderMgr(const ReaderMgr&);
0215 ReaderMgr& operator=(const ReaderMgr&);
0216
0217
0218
0219
0220 class ReaderData : public XMemory
0221 {
0222 public :
0223
0224
0225
0226 ReaderData
0227 ( XMLReader* const reader
0228 , XMLEntityDecl* const entity
0229 , const bool adoptEntity
0230 );
0231
0232 ~ReaderData();
0233
0234
0235
0236
0237 XMLReader* getReader() const;
0238 XMLEntityDecl* getEntity() const;
0239 bool getEntityAdopted() const;
0240
0241 XMLEntityDecl* releaseEntity();
0242
0243 private :
0244
0245
0246
0247 ReaderData();
0248 ReaderData(const ReaderData&);
0249 ReaderData& operator=(const ReaderData&);
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267 XMLReader* fReader;
0268 XMLEntityDecl* fEntity;
0269 bool fEntityAdopted;
0270 };
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321 ReaderData* fCurReaderData;
0322 XMLReader* fCurReader;
0323 XMLEntityHandler* fEntityHandler;
0324 RefStackOf<XMLEntityDecl>* fEntityStack;
0325 unsigned int fNextReaderNum;
0326 RefStackOf<ReaderData>* fReaderStack;
0327 bool fThrowEOE;
0328 XMLReader::XMLVersion fXMLVersion;
0329 bool fStandardUriConformant;
0330 MemoryManager* fMemoryManager;
0331 };
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342 inline XMLSize_t ReaderMgr::getCurrentReaderNum() const
0343 {
0344 return fCurReader->getReaderNum();
0345 }
0346
0347 inline const XMLReader* ReaderMgr::getCurrentReader() const
0348 {
0349 return fCurReader;
0350 }
0351
0352 inline XMLReader* ReaderMgr::getCurrentReader()
0353 {
0354 return fCurReader;
0355 }
0356
0357 inline bool ReaderMgr::getName(XMLBuffer& toFill)
0358 {
0359 toFill.reset();
0360 return fCurReader->getName(toFill, false);
0361 }
0362
0363 inline bool ReaderMgr::getQName(XMLBuffer& toFill, int *colonPosition)
0364 {
0365 toFill.reset();
0366 return fCurReader->getQName(toFill, colonPosition);
0367 }
0368
0369 inline bool ReaderMgr::getNameToken(XMLBuffer& toFill)
0370 {
0371 toFill.reset();
0372 return fCurReader->getName(toFill, true);
0373 }
0374
0375 inline bool ReaderMgr::getNextCharIfNot(const XMLCh chNotToGet, XMLCh& chGotten)
0376 {
0377 return fCurReader->getNextCharIfNot(chNotToGet, chGotten);
0378 }
0379
0380 inline void ReaderMgr::movePlainContentChars(XMLBuffer &dest)
0381 {
0382 fCurReader->movePlainContentChars(dest);
0383 }
0384
0385 inline bool ReaderMgr::getThrowEOE() const
0386 {
0387 return fThrowEOE;
0388 }
0389
0390 inline XMLFilePos ReaderMgr::getSrcOffset() const
0391 {
0392 return fCurReader? fCurReader->getSrcOffset() : 0;
0393 }
0394
0395 inline bool ReaderMgr::lookingAtChar(const XMLCh chToCheck)
0396 {
0397 return (chToCheck == peekNextChar());
0398 }
0399
0400 inline bool ReaderMgr::lookingAtSpace()
0401 {
0402 XMLCh c = peekNextChar();
0403 return fCurReader->isWhitespace(c);
0404 }
0405
0406 inline void ReaderMgr::setThrowEOE(const bool newValue)
0407 {
0408 fThrowEOE = newValue;
0409 }
0410
0411 inline void ReaderMgr::setStandardUriConformant(const bool newValue)
0412 {
0413 fStandardUriConformant = newValue;
0414 }
0415
0416 inline bool ReaderMgr::skippedString(const XMLCh* const toSkip)
0417 {
0418 return fCurReader->skippedString(toSkip);
0419 }
0420
0421 inline bool ReaderMgr::skippedStringLong(const XMLCh* const toSkip)
0422 {
0423 return fCurReader->skippedStringLong(toSkip);
0424 }
0425
0426 inline void ReaderMgr::skipToChar(const XMLCh toSkipTo)
0427 {
0428 XMLCh nextCh = 0;
0429 do
0430 {
0431
0432 nextCh = getNextChar();
0433 }
0434
0435 while((nextCh != toSkipTo) && nextCh!=0);
0436 }
0437
0438 inline void ReaderMgr::skipPastChar(const XMLCh toSkipPast)
0439 {
0440 XMLCh nextCh = 0;
0441 do
0442 {
0443
0444 nextCh = getNextChar();
0445 }
0446 while((nextCh != toSkipPast) && nextCh!=0);
0447 }
0448
0449 inline bool ReaderMgr::peekString(const XMLCh* const toPeek)
0450 {
0451 return fCurReader->peekString(toPeek);
0452 }
0453
0454 inline void ReaderMgr::setEntityHandler(XMLEntityHandler* const newHandler)
0455 {
0456 fEntityHandler = newHandler;
0457 }
0458
0459 inline void ReaderMgr::setXMLVersion(const XMLReader::XMLVersion version)
0460 {
0461 fXMLVersion = version;
0462 fCurReader->setXMLVersion(version);
0463 }
0464
0465
0466
0467
0468
0469
0470 class XMLPARSER_EXPORT ThrowEOEJanitor
0471 {
0472 public :
0473
0474
0475
0476 ThrowEOEJanitor(ReaderMgr* mgrTarget, const bool newValue) :
0477
0478 fOld(mgrTarget->getThrowEOE())
0479 , fMgr(mgrTarget)
0480 {
0481 mgrTarget->setThrowEOE(newValue);
0482 }
0483
0484 ~ThrowEOEJanitor()
0485 {
0486 fMgr->setThrowEOE(fOld);
0487 };
0488
0489 private :
0490
0491
0492
0493 ThrowEOEJanitor(const ThrowEOEJanitor&);
0494 ThrowEOEJanitor& operator=(const ThrowEOEJanitor&);
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505
0506
0507 bool fOld;
0508 ReaderMgr* fMgr;
0509 };
0510
0511 XERCES_CPP_NAMESPACE_END
0512
0513 #endif