source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/dom/deprecated/DOM_NamedNodeMap.hpp @ 2674

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