source: NonGTP/Xerces/xercesc/sax/AttributeList.hpp @ 188

Revision 188, 10.8 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in
16 *    the documentation and/or other materials provided with the
17 *    distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 *    if any, must include the following acknowledgment:
21 *       "This product includes software developed by the
22 *        Apache Software Foundation (http://www.apache.org/)."
23 *    Alternately, this acknowledgment may appear in the software itself,
24 *    if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Xerces" and "Apache Software Foundation" must
27 *    not be used to endorse or promote products derived from this
28 *    software without prior written permission. For written
29 *    permission, please contact apache\@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 *    nor may "Apache" appear in their name, without prior written
33 *    permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation, and was
51 * originally based on software copyright (c) 1999, International
52 * Business Machines, Inc., http://www.ibm.com .  For more information
53 * on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57/*
58 * $Log: AttributeList.hpp,v $
59 * Revision 1.3  2003/03/07 18:10:06  tng
60 * Return a reference instead of void for operator=
61 *
62 * Revision 1.2  2002/11/04 14:56:25  tng
63 * C++ Namespace Support.
64 *
65 * Revision 1.1.1.1  2002/02/01 22:22:07  peiyongz
66 * sane_include
67 *
68 * Revision 1.8  2000/03/02 19:54:34  roddey
69 * This checkin includes many changes done while waiting for the
70 * 1.1.0 code to be finished. I can't list them all here, but a list is
71 * available elsewhere.
72 *
73 * Revision 1.7  2000/02/24 20:12:54  abagchi
74 * Swat for removing Log from API docs
75 *
76 * Revision 1.6  2000/02/12 03:31:55  rahulj
77 * Removed duplicate CVS Log entries.
78 *
79 * Revision 1.5  2000/02/12 01:27:19  aruna1
80 * Documentation updated
81 *
82 * Revision 1.4  2000/02/09 02:12:21  abagchi
83 * Added getValue docs
84 *
85 * Revision 1.3  2000/02/06 07:47:57  rahulj
86 * Year 2K copyright swat.
87 *
88 * Revision 1.2  1999/12/15 19:58:31  roddey
89 * Added new convenience version of getValue() that takes a short character
90 * string for the attribute name.
91 *
92 * Revision 1.1.1.1  1999/11/09 01:07:43  twl
93 * Initial checkin
94 *
95 * Revision 1.2  1999/11/08 20:44:54  rahul
96 * Swat for adding in Product name and CVS comment log variable.
97 *
98 */
99
100#ifndef ATTRIBUTELIST_HPP
101#define ATTRIBUTELIST_HPP
102
103#include <xercesc/util/XercesDefs.hpp>
104
105XERCES_CPP_NAMESPACE_BEGIN
106
107/**
108  * Interface for an element's attribute specifications.
109  *
110  * The SAX parser implements this interface and passes an instance
111  * to the SAX application as the second argument of each startElement
112  * event.
113  *
114  * The instance provided will return valid results only during the
115  * scope of the startElement invocation (to save it for future
116  * use, the application must make a copy: the AttributeListImpl
117  * helper class provides a convenient constructor for doing so).
118  *
119  * An AttributeList includes only attributes that have been
120  * specified or defaulted: #IMPLIED attributes will not be included.
121  *
122  * There are two ways for the SAX application to obtain information
123  * from the AttributeList.  First, it can iterate through the entire
124  * list:
125  *
126  * <pre>
127  * public void startElement (String name, AttributeList atts) {
128  *   for (int i = 0; i < atts.getLength(); i++) {
129  *     String name = atts.getName(i);
130  *     String type = atts.getType(i);
131  *     String value = atts.getValue(i);
132  *     [...]
133  *   }
134  * }
135  * </pre>
136  *
137  * (Note that the result of getLength() will be zero if there
138  * are no attributes.)
139  *
140  * As an alternative, the application can request the value or
141  * type of specific attributes:
142  *
143  * <pre>
144  * public void startElement (String name, AttributeList atts) {
145  *   String identifier = atts.getValue("id");
146  *   String label = atts.getValue("label");
147  *   [...]
148  * }
149  * </pre>
150  *
151  * The AttributeListImpl helper class provides a convenience
152  * implementation for use by parser or application writers.
153  *
154  * @see DocumentHandler#startElement
155  * @see AttributeListImpl#AttributeListImpl
156  */
157
158class SAX_EXPORT AttributeList
159{
160public:
161    // -----------------------------------------------------------------------
162    //  Constructors and Destructor
163    // -----------------------------------------------------------------------
164    /** @name Constructors and Destructor */
165    //@{
166    /** Default constructor */
167    AttributeList()
168    {
169    }
170
171    /** Destructor */
172    virtual ~AttributeList()
173    {
174    }
175    //@}
176
177    /** @name The virtual attribute list interface */
178    //@{
179  /**
180    * Return the number of attributes in this list.
181    *
182    * The SAX parser may provide attributes in any
183    * arbitrary order, regardless of the order in which they were
184    * declared or specified.  The number of attributes may be
185    * zero.
186    *
187    * @return The number of attributes in the list.
188    */
189    virtual unsigned int getLength() const = 0;
190
191  /**
192    * Return the name of an attribute in this list (by position).
193    *
194    * The names must be unique: the SAX parser shall not include the
195    * same attribute twice.  Attributes without values (those declared
196    * #IMPLIED without a value specified in the start tag) will be
197    * omitted from the list.
198    *
199    * If the attribute name has a namespace prefix, the prefix
200    * will still be attached.
201    *
202    * @param index The index of the attribute in the list (starting at 0).
203    * @return The name of the indexed attribute, or null
204    *         if the index is out of range.
205    * @see #getLength
206    */
207    virtual const XMLCh* getName(const unsigned int index) const = 0;
208
209  /**
210    * Return the type of an attribute in the list (by position).
211    *
212    * The attribute type is one of the strings "CDATA", "ID",
213    * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
214    * or "NOTATION" (always in upper case).
215    *
216    * If the parser has not read a declaration for the attribute,
217    * or if the parser does not report attribute types, then it must
218    * return the value "CDATA" as stated in the XML 1.0 Recommentation
219    * (clause 3.3.3, "Attribute-Value Normalization").
220    *
221    * For an enumerated attribute that is not a notation, the
222    * parser will report the type as "NMTOKEN".
223    *
224    * @param index The index of the attribute in the list (starting at 0).
225    * @return The attribute type as a string, or
226    *         null if the index is out of range.
227    * @see #getLength
228    * @see #getType(String)
229    */
230    virtual const XMLCh* getType(const unsigned int index) const = 0;
231
232  /**
233    * Return the value of an attribute in the list (by position).
234    *
235    * If the attribute value is a list of tokens (IDREFS,
236    * ENTITIES, or NMTOKENS), the tokens will be concatenated
237    * into a single string separated by whitespace.
238    *
239    * @param index The index of the attribute in the list (starting at 0).
240    * @return The attribute value as a string, or
241    *         null if the index is out of range.
242    * @see #getLength
243    * @see #getValue(XMLCh*)
244    * @see #getValue(char *)
245    */
246    virtual const XMLCh* getValue(const unsigned int index) const = 0;
247
248  /**
249    * Return the type of an attribute in the list (by name).
250    *
251    * The return value is the same as the return value for
252    * getType(int).
253    *
254    * If the attribute name has a namespace prefix in the document,
255    * the application must include the prefix here.
256    *
257    * @param name The name of the attribute.
258    * @return The attribute type as a string, or null if no
259    *         such attribute exists.
260    * @see #getType(int)
261    */
262    virtual const XMLCh* getType(const XMLCh* const name) const = 0;
263
264  /**
265    * Return the value of an attribute in the list (by name).
266    *
267    * The return value is the same as the return value for
268    * getValue(int).
269    *
270    * If the attribute name has a namespace prefix in the document,
271    * the application must include the prefix here.
272    *
273    * @param name The name of the attribute in the list.
274    * @return The attribute value as a string, or null if
275    *         no such attribute exists.
276    * @see #getValue(int)
277    * @see #getValue(char *)
278    */
279    virtual const XMLCh* getValue(const XMLCh* const name) const = 0;
280
281  /**
282    * Return the value of an attribute in the list (by name).
283    *
284    * The return value is the same as the return value for
285    * getValue(int).
286    *
287    * If the attribute name has a namespace prefix in the document,
288    * the application must include the prefix here.
289    *
290    * @param name The name of the attribute in the list.
291    * @return The attribute value as a string, or null if
292    *         no such attribute exists.
293    * @see #getValue(int)
294    * @see #getValue(XMLCh*)
295    */
296    virtual const XMLCh* getValue(const char* const name) const = 0;
297    //@}
298
299private :
300    /* Constructors and operators */
301    /* Copy constructor */
302    AttributeList(const AttributeList&);
303    /* Assignment operator */
304    AttributeList& operator=(const AttributeList&);
305
306};
307
308XERCES_CPP_NAMESPACE_END
309
310#endif
Note: See TracBrowser for help on using the repository browser.