⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlscanner.hpp

📁 经典开源游戏glest的源代码
💻 HPP
📖 第 1 页 / 共 3 页
字号:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at *  *      http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//* * $Id: XMLScanner.hpp 568078 2007-08-21 11:43:25Z amassari $ */#if !defined(XMLSCANNER_HPP)#define XMLSCANNER_HPP#include <xercesc/framework/XMLBufferMgr.hpp>#include <xercesc/framework/XMLErrorCodes.hpp>#include <xercesc/framework/XMLRefInfo.hpp>#include <xercesc/util/PlatformUtils.hpp>#include <xercesc/util/NameIdPool.hpp>#include <xercesc/util/RefHashTableOf.hpp>#include <xercesc/util/SecurityManager.hpp>#include <xercesc/internal/ReaderMgr.hpp>#include <xercesc/internal/ElemStack.hpp>#include <xercesc/validators/DTD/DTDEntityDecl.hpp>#include <xercesc/framework/XMLAttr.hpp>#include <xercesc/framework/ValidationContext.hpp>#include <xercesc/validators/common/GrammarResolver.hpp>XERCES_CPP_NAMESPACE_BEGINclass InputSource;class XMLDocumentHandler;class XMLEntityHandler;class ErrorHandler;class DocTypeHandler;class XMLPScanToken;class XMLStringPool;class Grammar;class XMLValidator;class MemoryManager;class PSVIHandler;struct PSVIElemContext{    bool               fIsSpecified;    bool               fErrorOccurred;    int                fElemDepth;    int                fFullValidationDepth;    int                fNoneValidationDepth;    DatatypeValidator* fCurrentDV;    ComplexTypeInfo*   fCurrentTypeInfo;    const XMLCh*       fNormalizedValue;};//  This is the mondo scanner class, which does the vast majority of the//  work of parsing. It handles reading in input and spitting out events//  to installed handlers.class XMLPARSER_EXPORT XMLScanner : public XMemory, public XMLBufferFullHandler{public :    // -----------------------------------------------------------------------    //  Public class types    //    //  NOTE: These should really be private, but some of the compilers we    //  have to deal with are too stupid to understand this.    //    //  DeclTypes    //      Used by scanXMLDecl() to know what type of decl it should scan.    //      Text decls have slightly different rules from XMLDecls.    //    //  EntityExpRes    //      These are the values returned from the entity expansion method,    //      to indicate how it went.    //    //  XMLTokens    //      These represent the possible types of input we can get while    //      scanning content.    //    //  ValScheme    //      This indicates what the scanner should do in terms of validation.    //      'Auto' means if there is any int/ext subset, then validate. Else,    //      don't.    // -----------------------------------------------------------------------    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    );    void emitError    (        const   XMLErrs::Codes    toEmit        , const XMLExcepts::Codes   originalErrorCode        , const XMLCh* const        text1 = 0        , const XMLCh* const        text2 = 0        , const XMLCh* const        text3 = 0        , const XMLCh* const        text4 = 0    );    // -----------------------------------------------------------------------    //  Implementation of XMLBufferFullHandler interface    // -----------------------------------------------------------------------    virtual bool bufferFull(XMLBuffer& toSend)    {        sendCharData(toSend);        return true;    }    virtual Grammar::GrammarType getCurrentGrammarType() const;    // -----------------------------------------------------------------------    //  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;    bool getIdentityConstraintChecking() 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;    bool getGenerateSyntheticAnnotations() const;    bool getValidateAnnotations() const;    bool getIgnoreCachedDTD() const;    bool getIgnoreAnnotations() const;    bool getDisableDefaultEntityResolution() const;    bool getSkipDTDValidation() 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 setIdentityConstraintChecking(const bool identityConstraintChecking);    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);    void setInputBufferSize(const size_t bufferSize);    void setGenerateSyntheticAnnotations(const bool newValue);    void setValidateAnnotations(const bool newValue);    void setIgnoredCachedDTD(const bool newValue);    void setIgnoreAnnotations(const bool newValue);    void setDisableDefaultEntityResolution(const bool newValue);    void setSkipDTDValidation(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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -