/src/xerces-c/src/xercesc/dom/impl/DOMAttrImpl.hpp
Line | Count | Source |
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 1800911 2017-07-05 18:52:15Z scantor $ |
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> |
36 | | #include "DOMNodeBase.hpp" |
37 | | #include "DOMParentNode.hpp" |
38 | | #include "DOMNodeImpl.hpp" |
39 | | #include "DOMDocumentImpl.hpp" |
40 | | #include <xercesc/dom/DOMAttr.hpp> |
41 | | #include <xercesc/framework/XMLBuffer.hpp> |
42 | | #include "DOMNodeIDMap.hpp" |
43 | | |
44 | | XERCES_CPP_NAMESPACE_BEGIN |
45 | | |
46 | | class DOMElementImpl; |
47 | | class DOMTypeInfoImpl; |
48 | | |
49 | | class CDOM_EXPORT DOMAttrImpl: public DOMAttr, public HasDOMNodeImpl, public HasDOMParentImpl { |
50 | | |
51 | | public: |
52 | | DOMNodeImpl fNode; |
53 | | DOMParentNode fParent; |
54 | | const XMLCh *fName; |
55 | | |
56 | | protected: |
57 | | const DOMTypeInfoImpl *fSchemaType; |
58 | | |
59 | | public: |
60 | | DOMAttrImpl(DOMDocument *ownerDocument, const XMLCh *aName); |
61 | | DOMAttrImpl(const DOMAttrImpl &other, bool deep=false); |
62 | | virtual ~DOMAttrImpl(); |
63 | | |
64 | | public: |
65 | | // Add all functions that are pure virtual in DOMNODE |
66 | | DOMNODE_FUNCTIONS; |
67 | | |
68 | | // Add accessors for implementation bits. |
69 | | DOMNODEIMPL_DECL; |
70 | | DOMPARENTIMPL_DECL; |
71 | | |
72 | | public: |
73 | | virtual const XMLCh * getName() const; |
74 | | virtual bool getSpecified() const; |
75 | | virtual const XMLCh * getValue() const; |
76 | | virtual void setSpecified(bool arg); |
77 | | virtual void setValue(const XMLCh * value); |
78 | | virtual DOMElement * getOwnerElement() const; |
79 | | virtual bool isId() const; |
80 | | virtual const DOMTypeInfo* getSchemaTypeInfo() const; |
81 | | |
82 | | void setOwnerElement(DOMElement *ownerElem); //internal use only |
83 | | |
84 | | // helper function for DOM Level 3 renameNode |
85 | | virtual DOMNode* rename(const XMLCh* namespaceURI, const XMLCh* name); |
86 | | |
87 | | //helper function for DOM Level 3 TypeInfo |
88 | | virtual void setSchemaTypeInfo(const DOMTypeInfoImpl* typeInfo); |
89 | | |
90 | | // helper method that sets this attr to an idnode and places it into the document map |
91 | | virtual void addAttrToIDNodeMap(); |
92 | | |
93 | | // helper to remove this attr from from the id map if it is in there |
94 | | virtual void removeAttrFromIDNodeMap(); |
95 | | |
96 | | public: |
97 | | // Set attribute value fast. Assumptions: |
98 | | // |
99 | | // - node is not read-only |
100 | | // - no ID management is performed |
101 | | // - this attribute does not have a value |
102 | | // |
103 | | virtual void setValueFast (const XMLCh * value); |
104 | | |
105 | | protected: |
106 | | void getTextValue(DOMNode* node, XMLBuffer& buf) const; |
107 | | |
108 | | private: |
109 | | // ----------------------------------------------------------------------- |
110 | | // Unimplemented constructors and operators |
111 | | // ----------------------------------------------------------------------- |
112 | | DOMAttrImpl& operator=(const DOMAttrImpl&); |
113 | | }; |
114 | | |
115 | | inline void DOMAttrImpl::removeAttrFromIDNodeMap() |
116 | 0 | { |
117 | 0 | if (fNode.isIdAttr()) { |
118 | 0 | ((DOMDocumentImpl *)fParent.fOwnerDocument)->getNodeIDMap()->remove(this); |
119 | 0 | fNode.isIdAttr(false); |
120 | 0 | } |
121 | 0 | } |
122 | | |
123 | | inline void DOMAttrImpl::addAttrToIDNodeMap() |
124 | 0 | { |
125 | 0 | if (fNode.isIdAttr()) |
126 | 0 | return; |
127 | | |
128 | 0 | fNode.isIdAttr(true); |
129 | | |
130 | | // REVIST For now, we don't worry about what happens if the new |
131 | | // name conflicts as per setValue |
132 | 0 | DOMDocumentImpl *doc = (DOMDocumentImpl *)(fParent.fOwnerDocument); |
133 | |
|
134 | 0 | if (doc->fNodeIDMap == 0) |
135 | 0 | doc->fNodeIDMap = new (doc) DOMNodeIDMap(500, doc); |
136 | |
|
137 | 0 | doc->getNodeIDMap()->add(this); |
138 | 0 | } |
139 | | |
140 | | XERCES_CPP_NAMESPACE_END |
141 | | |
142 | | #endif |