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

📄 elemstack.hpp

📁 经典开源游戏glest的源代码
💻 HPP
📖 第 1 页 / 共 2 页
字号:
    //      fChildCount is how many of them are valid right now.    //    //      The fMapCapacity is how large fMap has grown so far. fMapCount    //      is how many of them are valid right now.    //    //      Note that we store the reader number we were in when we found the    //      start tag. We'll use this at the end tag to test for unbalanced    //      markup in entities.    //    //  MapModes    //      When a prefix is mapped to a namespace id, it matters whether the    //      QName being mapped is an attribute or name. Attributes are not    //      affected by an sibling xmlns attributes, whereas elements are    //      affected by its own xmlns attributes.    // -----------------------------------------------------------------------    struct StackElem : public XMemory    {        int                 fTopPrefix;                unsigned int        fCurrentURI;        unsigned int        fReaderNum;        unsigned int        fElemMaxLength;        XMLCh*              fThisElement;    };    enum MapModes    {        Mode_Attribute        , Mode_Element    };    // -----------------------------------------------------------------------    //  Constructors and Destructor    // -----------------------------------------------------------------------    WFElemStack(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);    ~WFElemStack();    // -----------------------------------------------------------------------    //  Stack access    // -----------------------------------------------------------------------    unsigned int addLevel();    unsigned int addLevel(const XMLCh* const toSet, const unsigned int toSetLen,                          const unsigned int readerNum);    const StackElem* popTop();    // -----------------------------------------------------------------------    //  Stack top access    // -----------------------------------------------------------------------    const StackElem* topElement() const;    void setElement(const XMLCh* const toSet, const unsigned int toSetLen,                    const unsigned int readerNum);    void setCurrentURI(unsigned int uri);    unsigned int getCurrentURI();    // -----------------------------------------------------------------------    //  Prefix map methods    // -----------------------------------------------------------------------    void addPrefix    (        const   XMLCh* const    prefixToAdd        , const unsigned int    uriId    );    unsigned int mapPrefixToURI    (        const   XMLCh* const    prefixToMap        , const MapModes        mode        ,       bool&           unknown    )   const;    // -----------------------------------------------------------------------    //  Miscellaneous methods    // -----------------------------------------------------------------------    bool isEmpty() const;    void reset    (        const   unsigned int    emptyId        , const unsigned int    unknownId        , const unsigned int    xmlId        , const unsigned int    xmlNSId    );private :    // -----------------------------------------------------------------------    //  Unimplemented constructors and operators    // -----------------------------------------------------------------------    WFElemStack(const WFElemStack&);    WFElemStack& operator=(const WFElemStack&);    // -----------------------------------------------------------------------    //  Private helper methods    // -----------------------------------------------------------------------    void expandMap();    void expandStack();    // -----------------------------------------------------------------------    //  Data members    //    //  fEmptyNamespaceId    //      This is the special URI id for the "" namespace, which is magic    //      because of the xmlns="" operation.    //    //  fGlobalPoolId    //      This is a special URI id that is returned when the namespace    //      prefix is "" and no one has explicitly mapped that prefix to an    //      explicit URI (or when they explicitly clear any such mapping,    //      which they can also do.) And also its prefix pool id, which is    //      stored here for fast access.    //    //  fPrefixPool    //      This is the prefix pool where prefixes are hashed and given unique    //      ids. These ids are used to track prefixes in the element stack.    //    //  fStack    //  fStackCapacity    //  fStackTop    //      This the stack array. Its an array of pointers to StackElem    //      structures. The capacity is the current high water mark of the    //      stack. The top is the current top of stack (i.e. the part of it    //      being used.)    //    //  fUnknownNamespaceId    //      This is the URI id for the special URI that is assigned to any    //      prefix which has not been mapped. This lets us keep going after    //      issuing the error.    //    //  fXMLNamespaceId    //  fXMLPoolId    //  fXMLNSNamespaceId    //  fXMLNSPoolId    //      These are the URI ids for the special URIs that are assigned to    //      the 'xml' and 'xmlns' namespaces. And also its prefix pool id,    //      which is stored here for fast access.    // -----------------------------------------------------------------------    unsigned int    fEmptyNamespaceId;    unsigned int    fGlobalPoolId;    unsigned int    fStackCapacity;    unsigned int    fStackTop;    unsigned int    fUnknownNamespaceId;    unsigned int    fXMLNamespaceId;    unsigned int    fXMLPoolId;    unsigned int    fXMLNSNamespaceId;    unsigned int    fXMLNSPoolId;    unsigned int    fMapCapacity;    PrefMapElem*    fMap;    StackElem**     fStack;    XMLStringPool   fPrefixPool;    MemoryManager*  fMemoryManager;};// ---------------------------------------------------------------------------//  ElemStack: Miscellaneous methods// ---------------------------------------------------------------------------inline bool ElemStack::isEmpty() const{    return (fStackTop == 0);}inline bool ElemStack::getValidationFlag(){    return fStack[fStackTop-1]->fValidationFlag;}inline void ElemStack::setValidationFlag(bool validationFlag){    fStack[fStackTop-1]->fValidationFlag = validationFlag;    return;}inline bool ElemStack::getCommentOrPISeen() const{    return fStack[fStackTop-1]->fCommentOrPISeen;}inline void ElemStack::setCommentOrPISeen(){    fStack[fStackTop-1]->fCommentOrPISeen = true;    return;}inline bool ElemStack::getReferenceEscaped() const{    return fStack[fStackTop-1]->fReferenceEscaped;}inline void ElemStack::setReferenceEscaped(){    fStack[fStackTop-1]->fReferenceEscaped = true;    return;}inline void ElemStack::setCurrentSchemaElemName(const XMLCh * const schemaElemName){    unsigned int schemaElemNameLen = XMLString::stringLen(schemaElemName);    unsigned int stackPos = fStackTop-1;        if(fStack[stackPos]->fSchemaElemNameMaxLen <= schemaElemNameLen)    {        XMLCh *tempStr = fStack[stackPos]->fSchemaElemName;        fStack[stackPos]->fSchemaElemNameMaxLen = schemaElemNameLen << 1;        fStack[stackPos]->fSchemaElemName = (XMLCh *)fMemoryManager->allocate((fStack[stackPos]->fSchemaElemNameMaxLen)*sizeof(XMLCh));        fMemoryManager->deallocate(tempStr);    }    XMLString::copyString(fStack[stackPos]->fSchemaElemName, schemaElemName);}inline XMLCh *ElemStack::getCurrentSchemaElemName(){    return fStack[fStackTop-1]->fSchemaElemName;}inline int ElemStack::getCurrentScope(){    return fStack[fStackTop-1]->fCurrentScope;}inline void ElemStack::setCurrentScope(int currentScope){    fStack[fStackTop-1]->fCurrentScope = currentScope;    return;}inline Grammar* ElemStack::getCurrentGrammar(){    return fStack[fStackTop-1]->fCurrentGrammar;}inline void ElemStack::setCurrentGrammar(Grammar* currentGrammar){    fStack[fStackTop-1]->fCurrentGrammar = currentGrammar;    return;}inline unsigned int ElemStack::getCurrentURI(){    return fStack[fStackTop-1]->fCurrentURI;}inline void ElemStack::setCurrentURI(unsigned int uri){    fStack[fStackTop-1]->fCurrentURI = uri;    return;}inline unsigned int ElemStack::getPrefixId(const XMLCh* const prefix) const{    return fPrefixPool.getId(prefix);}inline const XMLCh* ElemStack::getPrefixForId(unsigned int prefId) const{    return fPrefixPool.getValueForId(prefId);}inline void ElemStack::setPrefixColonPos(int colonPos){    fStack[fStackTop-1]->fPrefixColonPos = colonPos;} inline int ElemStack::getPrefixColonPos() const {    return fStack[fStackTop-1]->fPrefixColonPos;}// ---------------------------------------------------------------------------//  WFElemStack: Miscellaneous methods// ---------------------------------------------------------------------------inline bool WFElemStack::isEmpty() const{    return (fStackTop == 0);}inline unsigned int WFElemStack::getCurrentURI(){    return fStack[fStackTop-1]->fCurrentURI;}inline void WFElemStack::setCurrentURI(unsigned int uri){    fStack[fStackTop-1]->fCurrentURI = uri;    return;}XERCES_CPP_NAMESPACE_END#endif

⌨️ 快捷键说明

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