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