source: NonGTP/Xerces/xerces/include/xercesc/dom/deprecated/DOM_NamedNodeMap.hpp @ 358

Revision 358, 11.4 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
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_NamedNodeMap.hpp,v 1.5 2004/09/08 13:55:42 peiyongz Exp $
19 */
20
21#ifndef DOM_NamedNodeMap_HEADER_GUARD_
22#define DOM_NamedNodeMap_HEADER_GUARD_
23
24#include <xercesc/util/XercesDefs.hpp>
25
26#include "DOM_Node.hpp"
27
28XERCES_CPP_NAMESPACE_BEGIN
29
30
31class NamedNodeMapImpl;
32
33/**
34*  <code>NamedNodeMap</code>s  are used to
35* represent collections of nodes that can be accessed by name.
36*
37* Note that <code>NamedNodeMap</code> does not inherit from <code>NodeList</code>;
38* <code>NamedNodeMap</code>s are not maintained in any particular order.
39* Nodes contained in a <code>NamedNodeMap</code> may
40* also be accessed by an ordinal index, but this is simply to allow
41* convenient enumeration of the contents, and
42* does not imply that the DOM specifies an order to these Nodes.
43*/
44class DEPRECATED_DOM_EXPORT DOM_NamedNodeMap {
45private:
46    void     *fImpl;
47        short    flagElem;
48
49        static const unsigned short NNM_ELEMENT;
50        static const unsigned short NNM_OTHER; 
51
52public:
53    /** @name Constructors and assignment operator */
54    //@{
55    /**
56      * Default constructor for DOM_NamedNodeMap.  The resulting object does not
57      * refer to an actual DOM_NamedNodeMap node; it will compare == to 0, and is similar
58      * to a null object reference variable in Java. NamedNopes are instantiated
59      * by these methods:  DOM_Node::getAttributes, DOM_DocumentType::getEntities
60      * andDOM_DocumentType::getNotations
61      *
62      */
63    DOM_NamedNodeMap();
64
65    /**
66      * Copy constructor.  Creates a new <code>DOM_NamedNodeMap</code> reference object
67      * that refers to the same underlying NamedNodeMap as the original.
68      *
69      * @param other The object to be copied.
70      */
71    DOM_NamedNodeMap(const DOM_NamedNodeMap &other);
72
73    /**
74      * Assignment operator.
75      *
76      * @param other The object to be copied.
77      */
78    DOM_NamedNodeMap & operator = (const DOM_NamedNodeMap &other);
79
80    /**
81      * Assignment operator.
82      *
83      * @param other The object to be copied.
84      */
85    DOM_NamedNodeMap & operator = (const DOM_NullPtr *other);
86
87    //@}
88    /** @name Destructor. */
89    //@{
90    /**
91      * Destructor for DOM_NamedNodeMap.  The object being destroyed is the reference
92      * object, not the underlying NamedNodeMap itself.
93      *
94      * <p>Like most other DOM types in this implementation, memory management
95      * of named node maps is automatic.  Instances of DOM_NamedNodeMap function
96      * as references to an underlying heap based implementation object,
97      * and should never be explicitly new-ed or deleted in application code, but
98      * should appear only as local variables or function parameters.
99          *
100          */
101    ~DOM_NamedNodeMap();
102
103    //@}
104
105    /** @Comparisons. */
106    //@{
107    /**
108     *  Test whether this NamedNodeMap reference refers to the same underlying
109     *  named node map as the other reference object.  This does not
110     *  compare the contents of two different objects.
111     *
112     *  @param other The value to be compared
113     *  @return Returns true if the underlying named node map is same
114     */
115    bool operator == (const DOM_NamedNodeMap &other) const;
116
117    /**
118     *  Test whether this NamedNodeMap reference refers to a different underlying
119     *  named node map as the other reference object.  This does not
120     *  compare the contents of two different objects.
121     *
122     *  @param other The value to be compared
123     *  @return Returns true if the underlying named node map is different
124     */
125    bool operator != (const DOM_NamedNodeMap &other) const;
126
127
128    /**
129     *  Use this comparison operator to test whether a Named Node Map reference
130     *  is null.
131     *
132     *  @param p The value to be compared, which must be 0 or null.
133     *  @return Returns true if the named node map is null
134     */
135    bool operator == (const DOM_NullPtr *p) const;
136
137    /**
138     *  Use this comparison operator to test whether a Named Node Map reference
139     *  is not null.
140     *
141     *  @param p The value to be compared, which must not be 0 or null.
142     *  @return Returns true if the named node map is not null
143     */
144    bool operator != (const DOM_NullPtr *p) const;
145
146    //@}
147
148    /** @name Set functions. */
149    //@{
150
151    /**
152    * Adds a node using its <code>nodeName</code> attribute.
153    *
154    * <br>As the <code>nodeName</code> attribute is used to derive the name
155    * which the node must be stored under, multiple nodes of certain types
156    * (those that have a "special" string value) cannot be stored as the names
157    * would clash. This is seen as preferable to allowing nodes to be aliased.
158    * @param arg A node to store in a named node map. The node will later be
159    *   accessible using the value of the <code>nodeName</code> attribute of
160    *   the node. If a node with that name is already present in the map, it
161    *   is replaced by the new one.
162    * @return If the new <code>Node</code> replaces an existing node the
163    *   replaced <code>Node</code> is returned,
164    *   otherwise <code>null</code> is returned.
165    * @exception DOMException
166    *   WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
167    *   different document than the one that created the
168    *   <code>NamedNodeMap</code>.
169    *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this
170    *   <code>NamedNodeMap</code> is readonly.
171    *   <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
172    *   <code>Attr</code> that is already an attribute of another
173    *   <code>Element</code> object. The DOM user must explicitly clone
174    *   <code>Attr</code> nodes to re-use them in other elements.
175    */
176    DOM_Node               setNamedItem(DOM_Node arg);
177
178    //@}
179    /** @name Get functions. */
180    //@{
181
182    /**
183    * Returns the <code>index</code>th item in the map.
184    *
185    * If <code>index</code>
186    * is greater than or equal to the number of nodes in the map, this returns
187    * <code>null</code>.
188    * @param index Index into the map.
189    * @return The node at the <code>index</code>th position in the
190    *   <code>NamedNodeMap</code>, or <code>null</code> if that is not a valid
191    *   index.
192    */
193    DOM_Node               item(unsigned int index) const;
194
195    /**
196    * Retrieves a node specified by name.
197    *
198    * @param name The <code>nodeName</code> of a node to retrieve.
199    * @return A <code>DOM_Node</code> (of any type) with the specified <code>nodeName</code>, or
200    *   <code>null</code> if it does not identify any node in
201    *   the map.
202    */
203    DOM_Node               getNamedItem(const DOMString &name) const;
204
205    /**
206    * The number of nodes in the map.
207    *
208    * The range of valid child node indices is
209    * 0 to <code>length-1</code> inclusive.
210    */
211    unsigned int           getLength() const;
212
213    //@}
214    /** @name Functions to change the node collection. */
215    //@{
216
217    /**
218    * Removes a node specified by name.
219    *
220    * If the removed node is an
221    * <code>Attr</code> with a default value it is immediately replaced.
222    * @param name The <code>nodeName</code> of a node to remove.
223    * @return The node removed from the map or <code>null</code> if no node
224    *   with such a name exists.
225    * @exception DOMException
226    *   NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in
227    *   the map.
228    * <br>
229    *   NO_MODIFICATION_ALLOWED_ERR: Raised if this <code>NamedNodeMap</code>
230    *   is readonly.
231    */
232    DOM_Node               removeNamedItem(const DOMString &name);
233
234    //@}
235    /** @name Functions introduced in DOM Level 2. */
236    //@{
237
238    /**
239     * Retrieves a node specified by local name and namespace URI.
240     *
241     * @param namespaceURI The <em>namespace URI</em> of
242     *    the node to retrieve.
243     * @param localName The <em>local name</em> of the node to retrieve.
244     * @return A <code>DOM_Node</code> (of any type) with the specified
245     *    local name and namespace URI, or <code>null</code> if they do not
246     *    identify any node in the map.
247     */
248    DOM_Node               getNamedItemNS(const DOMString &namespaceURI,
249        const DOMString &localName);
250
251    /**
252     * Adds a node using its <CODE>namespaceURI</CODE> and <CODE>localName</CODE>.
253     *
254     * @param arg A node to store in a named node map. The node will later be
255     *       accessible using the value of the <CODE>namespaceURI</CODE> and
256     *       <CODE>localName</CODE> attribute of the node. If a node with those
257     *       namespace URI and local name is already present in the map, it is
258     *       replaced by the new one.
259     * @return If the new <code>DOM_Node</code> replaces an existing node the
260     *   replaced <code>DOM_Node</code> is returned,
261     *   otherwise <code>null</code> is returned.
262     * @exception DOMException
263     *   WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
264     *   different document than the one that created the
265     *   <code>DOM_NamedNodeMap</code>.
266     *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this
267     *   <code>vNamedNodeMap</code> is readonly.
268     *   <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
269     *   <code>DOM_Attr</code> that is already an attribute of another
270     *   <code>DOM_Element</code> object. The DOM user must explicitly clone
271     *   <code>DOM_Attr</code> nodes to re-use them in other elements.
272     */
273    DOM_Node               setNamedItemNS(DOM_Node arg);
274
275    /**
276     * Removes a node specified by local name and namespace URI.
277     *
278     * @param namespaceURI The <em>namespace URI</em> of
279     *    the node to remove.
280     * @param localName The <em>local name</em> of the
281     *    node to remove. When this <code>DOM_NamedNodeMap</code> contains the
282     *    attributes attached to an element, as returned by the attributes
283     *    attribute of the <code>DOM_Node</code> interface, if the removed
284     *    attribute is known to have a default value, an attribute
285     *    immediately appears containing the default value
286     *    as well as the corresponding namespace URI, local name, and prefix.
287     * @return The node removed from the map if a node with such a local name
288     *    and namespace URI exists.
289     * @exception DOMException
290     *   NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in
291     *   the map.
292     * <br>
293     *   NO_MODIFICATION_ALLOWED_ERR: Raised if this <code>DOM_NamedNodeMap</code>
294     *   is readonly.
295     */
296    DOM_Node               removeNamedItemNS(const DOMString &namespaceURI,
297        const DOMString &localName);
298
299    //@}
300
301 protected:
302
303    DOM_NamedNodeMap(NamedNodeMapImpl *impl);
304        DOM_NamedNodeMap(NodeImpl *impl);
305
306    friend class DOM_DocumentType;
307    friend class DOM_Node;
308
309
310};
311
312XERCES_CPP_NAMESPACE_END
313
314#endif
315
Note: See TracBrowser for help on using the repository browser.