Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:27:00

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_DOMATTRIMPL_HPP)
0023 #define XERCESC_INCLUDE_GUARD_DOMATTRIMPL_HPP
0024 
0025 //
0026 //  This file is part of the internal implementation of the C++ XML DOM.
0027 //  It should NOT be included or used directly by application programs.
0028 //
0029 //  Applications should include the file <xercesc/dom/DOM.hpp> for the entire
0030 //  DOM API, or xercesc/dom/DOM*.hpp for individual DOM classes, where the class
0031 //  name is substituded for the *.
0032 //
0033 
0034 
0035 #include <xercesc/util/XercesDefs.hpp>
0036 #include "DOMNodeBase.hpp"
0037 #include "DOMParentNode.hpp"
0038 #include "DOMNodeImpl.hpp"
0039 #include "DOMDocumentImpl.hpp"
0040 #include <xercesc/dom/DOMAttr.hpp>
0041 #include <xercesc/framework/XMLBuffer.hpp>
0042 #include "DOMNodeIDMap.hpp"
0043 
0044 XERCES_CPP_NAMESPACE_BEGIN
0045 
0046 class DOMElementImpl;
0047 class DOMTypeInfoImpl;
0048 
0049 class CDOM_EXPORT DOMAttrImpl: public DOMAttr, public HasDOMNodeImpl, public HasDOMParentImpl {
0050 
0051 public:
0052     DOMNodeImpl        fNode;
0053     DOMParentNode      fParent;
0054     const XMLCh       *fName;
0055 
0056 protected:
0057     const DOMTypeInfoImpl *fSchemaType;
0058 
0059 public:
0060     DOMAttrImpl(DOMDocument *ownerDocument, const XMLCh *aName);
0061     DOMAttrImpl(const DOMAttrImpl &other, bool deep=false);
0062     virtual ~DOMAttrImpl();
0063 
0064 public:
0065      // Add all functions that are pure virtual in DOMNODE
0066     DOMNODE_FUNCTIONS;
0067 
0068     // Add accessors for implementation bits.
0069     DOMNODEIMPL_DECL;
0070     DOMPARENTIMPL_DECL;
0071 
0072 public:
0073     virtual const XMLCh *       getName() const;
0074     virtual bool                getSpecified() const;
0075     virtual const XMLCh *       getValue() const;
0076     virtual void                setSpecified(bool arg);
0077     virtual void                setValue(const XMLCh * value);
0078     virtual DOMElement *        getOwnerElement() const;
0079     virtual bool                isId() const;
0080     virtual const DOMTypeInfo*  getSchemaTypeInfo() const;
0081 
0082     void setOwnerElement(DOMElement *ownerElem);    //internal use only
0083 
0084     // helper function for DOM Level 3 renameNode
0085     virtual DOMNode* rename(const XMLCh* namespaceURI, const XMLCh* name);
0086 
0087     //helper function for DOM Level 3 TypeInfo
0088     virtual void setSchemaTypeInfo(const DOMTypeInfoImpl* typeInfo);
0089 
0090    // helper method that sets this attr to an idnode and places it into the document map
0091    virtual void addAttrToIDNodeMap();
0092 
0093    // helper to remove this attr from from the id map if it is in there
0094    virtual void removeAttrFromIDNodeMap();
0095 
0096 public:
0097     // Set attribute value fast. Assumptions:
0098     //
0099     // - node is not read-only
0100     // - no ID management is performed
0101     // - this attribute does not have a value
0102     //
0103     virtual void setValueFast (const XMLCh * value);
0104 
0105 protected:
0106     void getTextValue(DOMNode* node, XMLBuffer& buf) const;
0107 
0108 private:
0109     // -----------------------------------------------------------------------
0110     //  Unimplemented constructors and operators
0111     // -----------------------------------------------------------------------
0112     DOMAttrImpl& operator=(const DOMAttrImpl&);
0113 };
0114 
0115 inline void DOMAttrImpl::removeAttrFromIDNodeMap()
0116 {
0117     if (fNode.isIdAttr()) {
0118         ((DOMDocumentImpl *)fParent.fOwnerDocument)->getNodeIDMap()->remove(this);
0119         fNode.isIdAttr(false);
0120     }
0121 }
0122 
0123 inline void DOMAttrImpl::addAttrToIDNodeMap()
0124 {
0125     if (fNode.isIdAttr())
0126         return;
0127 
0128     fNode.isIdAttr(true);
0129 
0130     // REVIST For now, we don't worry about what happens if the new
0131     // name conflicts as per setValue
0132     DOMDocumentImpl *doc = (DOMDocumentImpl *)(fParent.fOwnerDocument);
0133 
0134     if (doc->fNodeIDMap == 0)
0135         doc->fNodeIDMap = new (doc) DOMNodeIDMap(500, doc);
0136 
0137     doc->getNodeIDMap()->add(this);
0138 }
0139 
0140 XERCES_CPP_NAMESPACE_END
0141 
0142 #endif