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

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

xerces added

Line 
1#ifndef DOMNamedNodeMap_HEADER_GUARD_
2#define DOMNamedNodeMap_HEADER_GUARD_
3
4
5/*
6 * Copyright 2001-2002,2004 The Apache Software Foundation.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 *      http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21/*
22 * $Id: DOMNamedNodeMap.hpp,v 1.10 2004/09/08 13:55:39 peiyongz Exp $
23 */
24
25#include <xercesc/util/XercesDefs.hpp>
26
27XERCES_CPP_NAMESPACE_BEGIN
28
29
30class DOMNode;
31
32/**
33 *  <code>DOMNamedNodeMap</code>s  are used to
34 * represent collections of nodes that can be accessed by name.
35 *
36 * Note that <code>DOMNamedNodeMap</code> does not inherit from <code>DOMNodeList</code>;
37 * <code>DOMNamedNodeMap</code>s are not maintained in any particular order.
38 * Nodes contained in a <code>DOMNamedNodeMap</code> may
39 * also be accessed by an ordinal index, but this is simply to allow
40 * convenient enumeration of the contents, and
41 * does not imply that the DOM specifies an order to these Nodes.
42 *
43 * @since DOM Level 1
44 */
45class CDOM_EXPORT DOMNamedNodeMap {
46protected:
47    // -----------------------------------------------------------------------
48    //  Hidden constructors
49    // -----------------------------------------------------------------------
50    /** @name Hidden constructors */
51    //@{   
52    DOMNamedNodeMap() {};
53    //@}
54
55private:   
56    // -----------------------------------------------------------------------
57    // Unimplemented constructors and operators
58    // -----------------------------------------------------------------------
59    /** @name Unimplemented constructors and operators */
60    //@{
61    DOMNamedNodeMap(const DOMNamedNodeMap &);
62    DOMNamedNodeMap & operator = (const DOMNamedNodeMap &);
63    //@}
64
65public:
66    // -----------------------------------------------------------------------
67    //  All constructors are hidden, just the destructor is available
68    // -----------------------------------------------------------------------
69    /** @name Destructor */
70    //@{
71    /**
72     * Destructor
73     *
74     */
75    virtual ~DOMNamedNodeMap() {};
76    //@}
77
78    // -----------------------------------------------------------------------
79    //  Virtual DOMNamedNodeMap interface
80    // -----------------------------------------------------------------------
81    /** @name Functions introduced in DOM Level 1 */
82    //@{
83    // -----------------------------------------------------------------------
84    //  Setter methods
85    // -----------------------------------------------------------------------
86    /**
87     * Adds a node using its <code>nodeName</code> attribute.
88     *
89     * <br>As the <code>nodeName</code> attribute is used to derive the name
90     * which the node must be stored under, multiple nodes of certain types
91     * (those that have a "special" string value) cannot be stored as the names
92     * would clash. This is seen as preferable to allowing nodes to be aliased.
93     * @param arg A node to store in a named node map. The node will later be
94     *   accessible using the value of the <code>nodeName</code> attribute of
95     *   the node. If a node with that name is already present in the map, it
96     *   is replaced by the new one.
97     * @return If the new <code>DOMNode</code> replaces an existing node the
98     *   replaced <code>DOMNode</code> is returned,
99     *   otherwise <code>null</code> is returned.
100     * @exception DOMException
101     *   WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
102     *   different document than the one that created the
103     *   <code>DOMNamedNodeMap</code>.
104     *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this
105     *   <code>DOMNamedNodeMap</code> is readonly.
106     *   <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
107     *   <code>DOMAttr</code> that is already an attribute of another
108     *   <code>DOMElement</code> object. The DOM user must explicitly clone
109     *   <code>DOMAttr</code> nodes to re-use them in other elements.
110     * @since DOM Level 1
111     */
112    virtual DOMNode   *setNamedItem(DOMNode *arg) = 0;
113
114    // -----------------------------------------------------------------------
115    //  Getter methods
116    // -----------------------------------------------------------------------
117    /**
118     * Returns the <code>index</code>th item in the map.
119     *
120     * If <code>index</code>
121     * is greater than or equal to the number of nodes in the map, this returns
122     * <code>null</code>.
123     * @param index Index into the map.
124     * @return The node at the <code>index</code>th position in the
125     *   <code>DOMNamedNodeMap</code>, or <code>null</code> if that is not a valid
126     *   index.
127     * @since DOM Level 1
128     */
129    virtual DOMNode     *item(XMLSize_t index) const = 0;
130
131    /**
132     * Retrieves a node specified by name.
133     *
134     * @param name The <code>nodeName</code> of a node to retrieve.
135     * @return A <code>DOMNode</code> (of any type) with the specified <code>nodeName</code>, or
136     *   <code>null</code> if it does not identify any node in
137     *   the map.
138     * @since DOM Level 1
139     */
140    virtual DOMNode   *getNamedItem(const XMLCh *name) const = 0;
141
142    /**
143     * The number of nodes in the map.
144     *
145     * The range of valid child node indices is
146     * 0 to <code>length-1</code> inclusive.
147     * @since DOM Level 1
148     */
149    virtual XMLSize_t   getLength() const = 0;
150
151    // -----------------------------------------------------------------------
152    //  Node methods
153    // -----------------------------------------------------------------------
154    /**
155     * Removes a node specified by name.
156     *
157     * If the removed node is an
158     * <code>DOMAttr</code> with a default value it is immediately replaced.
159     * @param name The <code>nodeName</code> of a node to remove.
160     * @return The node removed from the map if a node with such a name exists.
161     * @exception DOMException
162     *   NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in
163     *   the map.
164     * <br>
165     *   NO_MODIFICATION_ALLOWED_ERR: Raised if this <code>DOMNamedNodeMap</code>
166     *   is readonly.
167     * @since DOM Level 1
168     */
169    virtual DOMNode    *removeNamedItem(const XMLCh *name) = 0;
170    //@}
171
172    /** @name Functions introduced in DOM Level 2 */
173    //@{
174    /**
175     * Retrieves a node specified by local name and namespace URI.
176     *
177     * @param namespaceURI The <em>namespace URI</em> of
178     *    the node to retrieve.
179     * @param localName The <em>local name</em> of the node to retrieve.
180     * @return A <code>DOMNode</code> (of any type) with the specified
181     *    local name and namespace URI, or <code>null</code> if they do not
182     *    identify any node in the map.
183     * @since DOM Level 2
184     */
185    virtual DOMNode   *getNamedItemNS(const XMLCh *namespaceURI,
186                                                const XMLCh *localName) const = 0;
187
188    /**
189     * Adds a node using its <CODE>namespaceURI</CODE> and <CODE>localName</CODE>.
190     *
191     * @param arg A node to store in a named node map. The node will later be
192     *       accessible using the value of the <CODE>namespaceURI</CODE> and
193     *       <CODE>localName</CODE> attribute of the node. If a node with those
194     *       namespace URI and local name is already present in the map, it is
195     *       replaced by the new one.
196     * @return If the new <code>DOMNode</code> replaces an existing node the
197     *   replaced <code>DOMNode</code> is returned,
198     *   otherwise <code>null</code> is returned.
199     * @exception DOMException
200     *   WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
201     *   different document than the one that created the
202     *   <code>DOMNamedNodeMap</code>.
203     *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this
204     *   <code>DOMNamedNodeMap</code> is readonly.
205     *   <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
206     *   <code>DOMAttr</code> that is already an attribute of another
207     *   <code>DOMElement</code> object. The DOM user must explicitly clone
208     *   <code>DOMAttr</code> nodes to re-use them in other elements.
209     * @since DOM Level 2
210     */
211    virtual DOMNode   *setNamedItemNS(DOMNode *arg) = 0;
212
213    /**
214     * Removes a node specified by local name and namespace URI.
215     *
216     * @param namespaceURI The <em>namespace URI</em> of
217     *    the node to remove.
218     * @param localName The <em>local name</em> of the
219     *    node to remove. When this <code>DOMNamedNodeMap</code> contains the
220     *    attributes attached to an element, as returned by the attributes
221     *    attribute of the <code>DOMNode</code> interface, if the removed
222     *    attribute is known to have a default value, an attribute
223     *    immediately appears containing the default value
224     *    as well as the corresponding namespace URI, local name, and prefix.
225     * @return The node removed from the map if a node with such a local name
226     *    and namespace URI exists.
227     * @exception DOMException
228     *   NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in
229     *   the map.
230     * <br>
231     *   NO_MODIFICATION_ALLOWED_ERR: Raised if this <code>DOMNamedNodeMap</code>
232     *   is readonly.
233     * @since DOM Level 2
234     */
235    virtual DOMNode     *removeNamedItemNS(const XMLCh *namespaceURI,
236                                                  const XMLCh *localName) = 0;
237    //@}
238
239};
240
241#define GetDOMNamedNodeMapMemoryManager   GET_INDIRECT_MM(fOwnerNode)
242
243XERCES_CPP_NAMESPACE_END
244
245#endif
246
Note: See TracBrowser for help on using the repository browser.