📄 xmlscanner.hpp
字号:
// ----------------------------------------------------------------------- enum DeclTypes { Decl_Text , Decl_XML }; enum EntityExpRes { EntityExp_Pushed , EntityExp_Returned , EntityExp_Failed }; enum XMLTokens { Token_CData , Token_CharData , Token_Comment , Token_EndTag , Token_EOF , Token_PI , Token_StartTag , Token_Unknown }; enum ValSchemes { Val_Never , Val_Always , Val_Auto }; // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- XMLScanner ( XMLValidator* const valToAdopt , GrammarResolver* const grammarResolver , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); XMLScanner ( XMLDocumentHandler* const docHandler , DocTypeHandler* const docTypeHandler , XMLEntityHandler* const entityHandler , XMLErrorReporter* const errReporter , XMLValidator* const valToAdopt , GrammarResolver* const grammarResolver , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~XMLScanner(); // ----------------------------------------------------------------------- // Error emitter methods // ----------------------------------------------------------------------- bool emitErrorWillThrowException(const XMLErrs::Codes toEmit); void emitError(const XMLErrs::Codes toEmit); void emitError ( const XMLErrs::Codes toEmit , const XMLCh* const text1 , const XMLCh* const text2 = 0 , const XMLCh* const text3 = 0 , const XMLCh* const text4 = 0 ); void emitError ( const XMLErrs::Codes toEmit , const char* const text1 , const char* const text2 = 0 , const char* const text3 = 0 , const char* const text4 = 0 ); // ----------------------------------------------------------------------- // Public pure virtual methods // ----------------------------------------------------------------------- virtual const XMLCh* getName() const = 0; virtual NameIdPool<DTDEntityDecl>* getEntityDeclPool() = 0; virtual const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const = 0; virtual unsigned int resolveQName ( const XMLCh* const qName , XMLBuffer& prefixBufToFill , const short mode , int& prefixColonPos ) = 0; virtual void scanDocument ( const InputSource& src ) = 0; virtual bool scanNext(XMLPScanToken& toFill) = 0; virtual Grammar* loadGrammar ( const InputSource& src , const short grammarType , const bool toCache = false ) = 0; // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- const XMLDocumentHandler* getDocHandler() const; XMLDocumentHandler* getDocHandler(); const DocTypeHandler* getDocTypeHandler() const; DocTypeHandler* getDocTypeHandler(); bool getDoNamespaces() const; ValSchemes getValidationScheme() const; bool getDoSchema() const; bool getValidationSchemaFullChecking() const; const XMLEntityHandler* getEntityHandler() const; XMLEntityHandler* getEntityHandler(); const XMLErrorReporter* getErrorReporter() const; XMLErrorReporter* getErrorReporter(); const ErrorHandler* getErrorHandler() const; ErrorHandler* getErrorHandler(); const PSVIHandler* getPSVIHandler() const; PSVIHandler* getPSVIHandler(); bool getExitOnFirstFatal() const; bool getValidationConstraintFatal() const; RefHashTableOf<XMLRefInfo>* getIDRefList(); const RefHashTableOf<XMLRefInfo>* getIDRefList() const; ValidationContext* getValidationContext(); bool getInException() const; /*bool getLastExtLocation ( XMLCh* const sysIdToFill , const unsigned int maxSysIdChars , XMLCh* const pubIdToFill , const unsigned int maxPubIdChars , XMLSSize_t& lineToFill , XMLSSize_t& colToFill ) const;*/ const Locator* getLocator() const; const ReaderMgr* getReaderMgr() const; unsigned int getSrcOffset() const; bool getStandalone() const; const XMLValidator* getValidator() const; XMLValidator* getValidator(); int getErrorCount(); const XMLStringPool* getURIStringPool() const; XMLStringPool* getURIStringPool(); bool getHasNoDTD() const; XMLCh* getExternalSchemaLocation() const; XMLCh* getExternalNoNamespaceSchemaLocation() const; SecurityManager* getSecurityManager() const; bool getLoadExternalDTD() const; bool getNormalizeData() const; bool isCachingGrammarFromParse() const; bool isUsingCachedGrammarInParse() const; bool getCalculateSrcOfs() const; Grammar* getRootGrammar() const; XMLReader::XMLVersion getXMLVersion() const; MemoryManager* getMemoryManager() const; ValueVectorOf<PrefMapElem*>* getNamespaceContext() const; unsigned int getPrefixId(const XMLCh* const prefix) const; const XMLCh* getPrefixForId(unsigned int prefId) const; // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- /** * When an attribute name has no prefix, unlike elements, it is not mapped * to the global namespace. So, in order to have something to map it to * for practical purposes, a id for an empty URL is created and used for * such names. * * @return The URL pool id of the URL for an empty URL "". */ unsigned int getEmptyNamespaceId() const; /** * When a prefix is found that has not been mapped, an error is issued. * However, if the parser has been instructed not to stop on the first * fatal error, it needs to be able to continue. To do so, it will map * that prefix tot his magic unknown namespace id. * * @return The URL pool id of the URL for the unknown prefix * namespace. */ unsigned int getUnknownNamespaceId() const; /** * The prefix 'xml' is a magic prefix, defined by the XML spec and * requiring no prior definition. This method returns the id for the * intrinsically defined URL for this prefix. * * @return The URL pool id of the URL for the 'xml' prefix. */ unsigned int getXMLNamespaceId() const; /** * The prefix 'xmlns' is a magic prefix, defined by the namespace spec * and requiring no prior definition. This method returns the id for the * intrinsically defined URL for this prefix. * * @return The URL pool id of the URL for the 'xmlns' prefix. */ unsigned int getXMLNSNamespaceId() const; /** * This method find the passed URI id in its URI pool and * copy the text of that URI into the passed buffer. */ bool getURIText ( const unsigned int uriId , XMLBuffer& uriBufToFill ) const; const XMLCh* getURIText(const unsigned int uriId) const; /* tell if the validator comes from user */ bool isValidatorFromUser(); /* tell if standard URI are forced */ bool getStandardUriConformant() const; // ----------------------------------------------------------------------- // Setter methods // ----------------------------------------------------------------------- void setDocHandler(XMLDocumentHandler* const docHandler); void setDocTypeHandler(DocTypeHandler* const docTypeHandler); void setDoNamespaces(const bool doNamespaces); void setEntityHandler(XMLEntityHandler* const docTypeHandler); void setErrorReporter(XMLErrorReporter* const errHandler); void setErrorHandler(ErrorHandler* const handler); void setPSVIHandler(PSVIHandler* const handler); void setURIStringPool(XMLStringPool* const stringPool); void setExitOnFirstFatal(const bool newValue); void setValidationConstraintFatal(const bool newValue); void setValidationScheme(const ValSchemes newScheme); void setValidator(XMLValidator* const valToAdopt); void setDoSchema(const bool doSchema); void setValidationSchemaFullChecking(const bool schemaFullChecking); void setHasNoDTD(const bool hasNoDTD); void cacheGrammarFromParse(const bool newValue); void useCachedGrammarInParse(const bool newValue); void setRootElemName(XMLCh* rootElemName); void setExternalSchemaLocation(const XMLCh* const schemaLocation); void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation); void setExternalSchemaLocation(const char* const schemaLocation); void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation); void setSecurityManager(SecurityManager* const securityManager); void setLoadExternalDTD(const bool loadDTD); void setNormalizeData(const bool normalizeData); void setCalculateSrcOfs(const bool newValue); void setParseSettings(XMLScanner* const refScanner); void setStandardUriConformant(const bool newValue); // ----------------------------------------------------------------------- // Mutator methods // ----------------------------------------------------------------------- void incrementErrorCount(void); // For use by XMLValidator // ----------------------------------------------------------------------- // Deprecated methods as of 3.2.0. Use getValidationScheme() and // setValidationScheme() instead. // ----------------------------------------------------------------------- bool getDoValidation() const; void setDoValidation(const bool validate); // ----------------------------------------------------------------------- // Document scanning methods // // scanDocument() does the entire source document. scanFirst(), // scanNext(), and scanReset() support a progressive parse. // ----------------------------------------------------------------------- void scanDocument ( const XMLCh* const systemId ); void scanDocument ( const char* const systemId ); bool scanFirst ( const InputSource& src , XMLPScanToken& toFill ); bool scanFirst ( const XMLCh* const systemId , XMLPScanToken& toFill ); bool scanFirst ( const char* const systemId , XMLPScanToken& toFill ); void scanReset(XMLPScanToken& toFill); bool checkXMLDecl(bool startWithAngle); // ----------------------------------------------------------------------- // Grammar preparsing methods // ----------------------------------------------------------------------- Grammar* loadGrammar ( const XMLCh* const systemId , const short grammarType , const bool toCache = false ); Grammar* loadGrammar ( const char* const systemId , const short grammarType , const bool toCache = false ); // ----------------------------------------------------------------------- // Notification that lazy data has been deleted // ----------------------------------------------------------------------- static void reinitScannerMutex(); static void reinitMsgLoader();protected: // ----------------------------------------------------------------------- // Protected pure virtual methods // ----------------------------------------------------------------------- virtual void scanCDSection() = 0; virtual void scanCharData(XMLBuffer& toToUse) = 0; virtual EntityExpRes scanEntityRef ( const bool inAttVal , XMLCh& firstCh , XMLCh& secondCh , bool& escaped ) = 0; virtual void scanDocTypeDecl() = 0; virtual void scanReset(const InputSource& src) = 0; virtual void sendCharData(XMLBuffer& toSend) = 0; // ----------------------------------------------------------------------- // Protected scanning methods // ----------------------------------------------------------------------- bool scanCharRef(XMLCh& toFill, XMLCh& second); void scanComment(); bool scanEq(); void scanMiscellaneous(); void scanPI(); void scanProlog(); void scanXMLDecl(const DeclTypes type); // ----------------------------------------------------------------------- // Private helper methods // ----------------------------------------------------------------------- void checkIDRefs(); bool isLegalToken(const XMLPScanToken& toCheck); XMLTokens senseNextToken(unsigned int& orgReader); void initValidator(XMLValidator* theValidator); inline void resetValidationContext(); unsigned int *getNewUIntPtr(); void resetUIntPool(); void recreateUIntPool(); // ----------------------------------------------------------------------- // Data members // // fAttrList // Every time we get a new element start tag, we have to pass to // the document handler the attributes found. To make it more // efficient we keep this ref vector of XMLAttr objects around. We // just reuse it over and over, allowing it to grow to meet the // peak need. //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -