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: DOM_Attr.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef DOM_Attr_HEADER_GUARD_ |
---|
23 | #define DOM_Attr_HEADER_GUARD_ |
---|
24 | |
---|
25 | #include <xercesc/util/XercesDefs.hpp> |
---|
26 | #include "DOM_Node.hpp" |
---|
27 | #include "DOM_Element.hpp" |
---|
28 | |
---|
29 | XERCES_CPP_NAMESPACE_BEGIN |
---|
30 | |
---|
31 | |
---|
32 | class AttrImpl; |
---|
33 | |
---|
34 | /** |
---|
35 | * The <code>DOM_Attr</code> class refers to an attribute of an XML element. |
---|
36 | * |
---|
37 | * Typically the allowable values for the |
---|
38 | * attribute are defined in a documenttype definition. |
---|
39 | * <p><code>DOM_Attr</code> objects inherit the <code>DOM_Node</code> interface, but |
---|
40 | * since attributes are not actually child nodes of the elements they are associated with, the |
---|
41 | * DOM does not consider them part of the document tree. Thus, the |
---|
42 | * <code>DOM_Node</code> attributes <code>parentNode</code>, |
---|
43 | * <code>previousSibling</code>, and <code>nextSibling</code> have a null |
---|
44 | * value for <code>DOM_Attr</code> objects. The DOM takes the view that |
---|
45 | * attributes are properties of elements rather than having a separate |
---|
46 | * identity from the elements they are associated with; this should make it |
---|
47 | * more efficient to implement such features as default attributes associated |
---|
48 | * with all elements of a given type. Furthermore, attribute nodes |
---|
49 | * may not be immediate children of a <code>DocumentFragment</code>. However, |
---|
50 | * they can be associated with <code>Element</code> nodes contained within a |
---|
51 | * <code>DocumentFragment</code>. In short, users of the DOM |
---|
52 | * need to be aware that <code>Attr</code> nodes have some things in common |
---|
53 | * with other objects inheriting the <code>Node</code> interface, but they |
---|
54 | * also are quite distinct. |
---|
55 | * |
---|
56 | */ |
---|
57 | class DEPRECATED_DOM_EXPORT DOM_Attr: public DOM_Node { |
---|
58 | |
---|
59 | public: |
---|
60 | /** @name Constructors and assignment operators */ |
---|
61 | //@{ |
---|
62 | /** |
---|
63 | * Default constructor for DOM_Attr. The resulting object does not |
---|
64 | * refer to any Attribute; it will compare == to 0, and is similar |
---|
65 | * to a null object reference variable in Java. |
---|
66 | * |
---|
67 | */ |
---|
68 | DOM_Attr(); |
---|
69 | |
---|
70 | public: |
---|
71 | |
---|
72 | /** |
---|
73 | * Copy constructor. Creates a new <code>DOM_Attr</code> that refers to the |
---|
74 | * same underlying Attribute as the original. See also DOM_Node::clone(), |
---|
75 | * which will copy an actual attribute, rather than just creating a new |
---|
76 | * reference to the original attribute. |
---|
77 | * |
---|
78 | * @param other The source attribute reference object |
---|
79 | */ |
---|
80 | DOM_Attr(const DOM_Attr &other); |
---|
81 | |
---|
82 | /** |
---|
83 | * Assignment operator |
---|
84 | * |
---|
85 | * @param other The source attribute object |
---|
86 | */ |
---|
87 | DOM_Attr & operator = (const DOM_Attr &other); |
---|
88 | |
---|
89 | /** |
---|
90 | * Assignment operator. This overloaded variant is provided for |
---|
91 | * the sole purpose of setting a DOM_Node reference variable to |
---|
92 | * zero. Nulling out a reference variable in this way will decrement |
---|
93 | * the reference count on the underlying Node object that the variable |
---|
94 | * formerly referenced. This effect is normally obtained when reference |
---|
95 | * variable goes out of scope, but zeroing them can be useful for |
---|
96 | * global instances, or for local instances that will remain in scope |
---|
97 | * for an extended time, when the storage belonging to the underlying |
---|
98 | * node needs to be reclaimed. |
---|
99 | * |
---|
100 | * @param val Only a value of 0, or null, is allowed. |
---|
101 | */ |
---|
102 | DOM_Attr & operator = (const DOM_NullPtr *val); |
---|
103 | |
---|
104 | |
---|
105 | |
---|
106 | //@} |
---|
107 | /** @name Destructor */ |
---|
108 | //@{ |
---|
109 | |
---|
110 | /** |
---|
111 | * Destructor. The object being destroyed is a reference to the Attribute |
---|
112 | * "node", not the underlying attribute itself. |
---|
113 | * |
---|
114 | */ |
---|
115 | ~DOM_Attr(); |
---|
116 | //@} |
---|
117 | |
---|
118 | /** @name Getter functions */ |
---|
119 | //@{ |
---|
120 | /** |
---|
121 | * Returns the name of this attribute. |
---|
122 | */ |
---|
123 | DOMString getName() const; |
---|
124 | |
---|
125 | /** |
---|
126 | * |
---|
127 | * Returns true if the attribute received its value explicitly in the |
---|
128 | * XML document, or if a value was assigned programatically with |
---|
129 | * the setValue function. Returns false if the attribute value |
---|
130 | * came from the default value declared in the document's DTD. |
---|
131 | */ |
---|
132 | bool getSpecified() const; |
---|
133 | |
---|
134 | /** |
---|
135 | * Returns the value of the attribute. |
---|
136 | * |
---|
137 | * The value of the attribute is returned as a string. |
---|
138 | * Character and general entity references are replaced with their values. |
---|
139 | */ |
---|
140 | DOMString getValue() const; |
---|
141 | |
---|
142 | //@} |
---|
143 | /** @name Setter functions */ |
---|
144 | //@{ |
---|
145 | /** |
---|
146 | * Sets the value of the attribute. A text node with the unparsed contents |
---|
147 | * of the string will be created. |
---|
148 | * |
---|
149 | * @param value The value of the DOM attribute to be set |
---|
150 | */ |
---|
151 | void setValue(const DOMString &value); |
---|
152 | //@} |
---|
153 | |
---|
154 | /** @name Functions introduced in DOM Level 2. */ |
---|
155 | //@{ |
---|
156 | /** |
---|
157 | * The <code>DOM_Element</code> node this attribute is attached to or |
---|
158 | * <code>null</code> if this attribute is not in use. |
---|
159 | * |
---|
160 | */ |
---|
161 | DOM_Element getOwnerElement() const; |
---|
162 | //@} |
---|
163 | |
---|
164 | protected: |
---|
165 | DOM_Attr(AttrImpl *attr); |
---|
166 | |
---|
167 | friend class DOM_Element; |
---|
168 | friend class DOM_Document; |
---|
169 | |
---|
170 | }; |
---|
171 | |
---|
172 | XERCES_CPP_NAMESPACE_END |
---|
173 | |
---|
174 | #endif |
---|
175 | |
---|
176 | |
---|