source: icXML/icXML-devel/src/xercesc/dom/impl/DOMAttrImpl.hpp @ 2777

Last change on this file since 2777 was 2777, checked in by cameron, 7 years ago

Set up to use xercesc/icxercesc root-relative paths for all includes

File size: 4.3 KB
RevLine 
[2722]1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: DOMAttrImpl.hpp 678709 2008-07-22 10:56:56Z borisk $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_DOMATTRIMPL_HPP)
23#define XERCESC_INCLUDE_GUARD_DOMATTRIMPL_HPP
24
25//
26//  This file is part of the internal implementation of the C++ XML DOM.
27//  It should NOT be included or used directly by application programs.
28//
29//  Applications should include the file <xercesc/dom/DOM.hpp> for the entire
30//  DOM API, or xercesc/dom/DOM*.hpp for individual DOM classes, where the class
31//  name is substituded for the *.
32//
33
34
35#include <xercesc/util/XercesDefs.hpp>
[2777]36#include <xercesc/dom/impl/DOMParentNode.hpp>
37#include <icxercesc/dom/impl/DOMNodeImpl.hpp>
38#include <xercesc/dom/impl/DOMDocumentImpl.hpp>
[2722]39#include <xercesc/dom/DOMAttr.hpp>
40#include <icxercesc/framework/XMLBuffer.hpp>
[2777]41#include <xercesc/dom/impl/DOMNodeIDMap.hpp>
[2722]42
43XERCES_CPP_NAMESPACE_BEGIN
44
45class DOMElementImpl;
46class DOMTypeInfoImpl;
47
48class CDOM_EXPORT DOMAttrImpl: public DOMAttr {
49
50public:
51    DOMNodeImpl        fNode;
52    DOMParentNode      fParent;
53    const XMLCh       *fName;
54
55protected:
56    const DOMTypeInfoImpl *fSchemaType;
57
58public:
59    DOMAttrImpl(DOMDocument *ownerDocument, const XMLCh *aName);
60    DOMAttrImpl(const DOMAttrImpl &other, bool deep=false);
61    virtual ~DOMAttrImpl();
62
63public:
64     // Add all functions that are pure virtual in DOMNODE
65    DOMNODE_FUNCTIONS;
66
67public:
68    virtual const XMLCh *       getName() const;
69    virtual bool                getSpecified() const;
70    virtual const XMLCh *       getValue() const;
71    virtual void                setSpecified(bool arg);
72    virtual void                setValue(const XMLCh * value);
73    virtual DOMElement *        getOwnerElement() const;
74    virtual bool                isId() const;
75    virtual const DOMTypeInfo*  getSchemaTypeInfo() const;
76
77    void setOwnerElement(DOMElement *ownerElem);    //internal use only
78
79    // helper function for DOM Level 3 renameNode
80    virtual DOMNode* rename(const XMLCh* namespaceURI, const XMLCh* name);
81
82    //helper function for DOM Level 3 TypeInfo
83    virtual void setSchemaTypeInfo(const DOMTypeInfoImpl* typeInfo);
84
85   // helper method that sets this attr to an idnode and places it into the document map
86   virtual void addAttrToIDNodeMap();
87
88   // helper to remove this attr from from the id map if it is in there
89   virtual void removeAttrFromIDNodeMap();
90
91public:
92    // Set attribute value fast. Assumptions:
93    //
94    // - node is not read-only
95    // - no ID management is performed
96    // - this attribute does not have a value
97    //
98    virtual void setValueFast (const XMLCh * value);
99
100protected:
101    void getTextValue(DOMNode* node, XMLBuffer& buf) const;
102
103private:
104    // -----------------------------------------------------------------------
105    //  Unimplemented constructors and operators
106    // -----------------------------------------------------------------------
107    DOMAttrImpl& operator=(const DOMAttrImpl&);
108};
109
110inline void DOMAttrImpl::removeAttrFromIDNodeMap()
111{
112    if (fNode.isIdAttr()) {
113        ((DOMDocumentImpl *)fParent.fOwnerDocument)->getNodeIDMap()->remove(this);
114        fNode.isIdAttr(false);
115    }
116}
117
118inline void DOMAttrImpl::addAttrToIDNodeMap()
119{
120    if (fNode.isIdAttr())
121        return;
122
123    fNode.isIdAttr(true);
124
125    // REVIST For now, we don't worry about what happens if the new
126    // name conflicts as per setValue
127    DOMDocumentImpl *doc = (DOMDocumentImpl *)(fParent.fOwnerDocument);
128
129    if (doc->fNodeIDMap == 0)
130        doc->fNodeIDMap = new (doc) DOMNodeIDMap(500, doc);
131
132    doc->getNodeIDMap()->add(this);
133}
134
135XERCES_CPP_NAMESPACE_END
136
137#endif
Note: See TracBrowser for help on using the repository browser.