source: trunk/doc/html/qxml-h.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 18.8 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/include/qxml.h:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>qxml.h Include File</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>qxml.h</h1>
33
34<p>This is the verbatim text of the qxml.h include file. It is provided only for illustration; the copyright remains with Trolltech.
35<hr>
36<pre>
37/****************************************************************************
38** $Id: qxml-h.html 2051 2007-02-21 10:04:20Z chehrlic $
39**
40** Definition of QXmlSimpleReader and related classes.
41**
42** Created : 000518
43**
44** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
45**
46** This file is part of the xml module of the Qt GUI Toolkit.
47**
48** This file may be distributed under the terms of the Q Public License
49** as defined by Trolltech ASA of Norway and appearing in the file
50** LICENSE.QPL included in the packaging of this file.
51**
52** This file may be distributed and/or modified under the terms of the
53** GNU General Public License version 2 as published by the Free Software
54** Foundation and appearing in the file LICENSE.GPL included in the
55** packaging of this file.
56**
57** Licensees holding valid Qt Enterprise Edition licenses may use this
58** file in accordance with the Qt Commercial License Agreement provided
59** with the Software.
60**
61** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
62** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
63**
64** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
65** information about Qt Commercial License Agreements.
66** See http://www.trolltech.com/qpl/ for QPL licensing information.
67** See http://www.trolltech.com/gpl/ for GPL licensing information.
68**
69** Contact info@trolltech.com if any conditions of this licensing are
70** not clear to you.
71**
72**********************************************************************/
73
74#ifndef QXML_H
75#define QXML_H
76
77#ifndef QT_H
78#include "qtextstream.h"
79#include "qfile.h"
80#include "qstring.h"
81#include "qstringlist.h"
82#include "qvaluevector.h"
83#endif // QT_H
84
85#if !defined(QT_MODULE_XML) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_XML )
86#define QM_EXPORT_XML
87#else
88#define QM_EXPORT_XML Q_EXPORT
89#endif
90
91#ifndef QT_NO_XML
92
93class QXmlNamespaceSupport;
94class QXmlAttributes;
95class QXmlContentHandler;
96class QXmlDefaultHandler;
97class QXmlDTDHandler;
98class QXmlEntityResolver;
99class QXmlErrorHandler;
100class QXmlLexicalHandler;
101class QXmlDeclHandler;
102class QXmlInputSource;
103class QXmlLocator;
104class QXmlNamespaceSupport;
105class QXmlParseException;
106
107class QXmlReader;
108class QXmlSimpleReader;
109
110class QXmlSimpleReaderPrivate;
111class QXmlNamespaceSupportPrivate;
112class QXmlAttributesPrivate;
113class QXmlInputSourcePrivate;
114class QXmlParseExceptionPrivate;
115class QXmlLocatorPrivate;
116class QXmlDefaultHandlerPrivate;
117
118
119//
120// SAX Namespace Support
121//
122
123class QM_EXPORT_XML QXmlNamespaceSupport
124{
125public:
126 QXmlNamespaceSupport();
127 ~QXmlNamespaceSupport();
128
129 void setPrefix( const QString&amp;, const QString&amp; );
130
131 QString prefix( const QString&amp; ) const;
132 QString uri( const QString&amp; ) const;
133 void splitName( const QString&amp;, QString&amp;, QString&amp; ) const;
134 void processName( const QString&amp;, bool, QString&amp;, QString&amp; ) const;
135 QStringList prefixes() const;
136 QStringList prefixes( const QString&amp; ) const;
137
138 void pushContext();
139 void popContext();
140 void reset();
141
142private:
143 QXmlNamespaceSupportPrivate *d;
144
145 friend class QXmlSimpleReader;
146};
147
148
149//
150// SAX Attributes
151//
152
153class QM_EXPORT_XML QXmlAttributes
154{
155public:
156 QXmlAttributes() {}
157 virtual ~QXmlAttributes() {}
158
159 int index( const QString&amp; qName ) const;
160 int index( const QString&amp; uri, const QString&amp; localPart ) const;
161 int length() const;
162 int count() const;
163 QString localName( int index ) const;
164 QString qName( int index ) const;
165 QString uri( int index ) const;
166 QString type( int index ) const;
167 QString type( const QString&amp; qName ) const;
168 QString type( const QString&amp; uri, const QString&amp; localName ) const;
169 QString value( int index ) const;
170 QString value( const QString&amp; qName ) const;
171 QString value( const QString&amp; uri, const QString&amp; localName ) const;
172
173 void clear();
174 void append( const QString &amp;qName, const QString &amp;uri, const QString &amp;localPart, const QString &amp;value );
175
176private:
177 QStringList qnameList;
178 QStringList uriList;
179 QStringList localnameList;
180 QStringList valueList;
181
182 QXmlAttributesPrivate *d;
183};
184
185//
186// SAX Input Source
187//
188
189class QM_EXPORT_XML QXmlInputSource
190{
191public:
192 QXmlInputSource();
193 QXmlInputSource( QIODevice *dev );
194 QXmlInputSource( QFile&amp; file ); // obsolete
195 QXmlInputSource( QTextStream&amp; stream ); // obsolete
196 virtual ~QXmlInputSource();
197
198 virtual void setData( const QString&amp; dat );
199 virtual void setData( const QByteArray&amp; dat );
200 virtual void fetchData();
201 virtual QString data();
202 virtual QChar next();
203 virtual void reset();
204
205 static const QChar EndOfData;
206 static const QChar EndOfDocument;
207
208protected:
209 virtual QString fromRawData( const QByteArray &amp;data, bool beginning = FALSE );
210
211private:
212 void init();
213
214 QIODevice *inputDevice;
215 QTextStream *inputStream;
216
217 QString str;
218 const QChar *unicode;
219 int pos;
220 int length;
221 bool nextReturnedEndOfData;
222 QTextDecoder *encMapper;
223
224 QXmlInputSourcePrivate *d;
225};
226
227//
228// SAX Exception Classes
229//
230
231class QM_EXPORT_XML QXmlParseException
232{
233public:
234 QXmlParseException( const QString&amp; name="", int c=-1, int l=-1, const QString&amp; p="", const QString&amp; s="" )
235 : msg( name ), column( c ), line( l ), pub( p ), sys( s )
236 { }
237
238 int columnNumber() const;
239 int lineNumber() const;
240 QString publicId() const;
241 QString systemId() const;
242 QString message() const;
243
244private:
245 QString msg;
246 int column;
247 int line;
248 QString pub;
249 QString sys;
250
251 QXmlParseExceptionPrivate *d;
252};
253
254
255//
256// XML Reader
257//
258
259class QM_EXPORT_XML QXmlReader
260{
261public:
262 virtual bool feature( const QString&amp; name, bool *ok = 0 ) const = 0;
263 virtual void setFeature( const QString&amp; name, bool value ) = 0;
264 virtual bool hasFeature( const QString&amp; name ) const = 0;
265 virtual void* property( const QString&amp; name, bool *ok = 0 ) const = 0;
266 virtual void setProperty( const QString&amp; name, void* value ) = 0;
267 virtual bool hasProperty( const QString&amp; name ) const = 0;
268 virtual void setEntityResolver( QXmlEntityResolver* handler ) = 0;
269 virtual QXmlEntityResolver* entityResolver() const = 0;
270 virtual void setDTDHandler( QXmlDTDHandler* handler ) = 0;
271 virtual QXmlDTDHandler* DTDHandler() const = 0;
272 virtual void setContentHandler( QXmlContentHandler* handler ) = 0;
273 virtual QXmlContentHandler* contentHandler() const = 0;
274 virtual void setErrorHandler( QXmlErrorHandler* handler ) = 0;
275 virtual QXmlErrorHandler* errorHandler() const = 0;
276 virtual void setLexicalHandler( QXmlLexicalHandler* handler ) = 0;
277 virtual QXmlLexicalHandler* lexicalHandler() const = 0;
278 virtual void setDeclHandler( QXmlDeclHandler* handler ) = 0;
279 virtual QXmlDeclHandler* declHandler() const = 0;
280 virtual bool parse( const QXmlInputSource&amp; input ) = 0;
281 virtual bool parse( const QXmlInputSource* input ) = 0;
282};
283
284class QM_EXPORT_XML QXmlSimpleReader : public QXmlReader
285{
286public:
287 QXmlSimpleReader();
288 virtual ~QXmlSimpleReader();
289
290 bool feature( const QString&amp; name, bool *ok = 0 ) const;
291 void setFeature( const QString&amp; name, bool value );
292 bool hasFeature( const QString&amp; name ) const;
293
294 void* property( const QString&amp; name, bool *ok = 0 ) const;
295 void setProperty( const QString&amp; name, void* value );
296 bool hasProperty( const QString&amp; name ) const;
297
298 void setEntityResolver( QXmlEntityResolver* handler );
299 QXmlEntityResolver* entityResolver() const;
300 void setDTDHandler( QXmlDTDHandler* handler );
301 QXmlDTDHandler* DTDHandler() const;
302 void setContentHandler( QXmlContentHandler* handler );
303 QXmlContentHandler* contentHandler() const;
304 void setErrorHandler( QXmlErrorHandler* handler );
305 QXmlErrorHandler* errorHandler() const;
306 void setLexicalHandler( QXmlLexicalHandler* handler );
307 QXmlLexicalHandler* lexicalHandler() const;
308 void setDeclHandler( QXmlDeclHandler* handler );
309 QXmlDeclHandler* declHandler() const;
310
311 bool parse( const QXmlInputSource&amp; input );
312 bool parse( const QXmlInputSource* input );
313 virtual bool parse( const QXmlInputSource* input, bool incremental );
314 virtual bool parseContinue();
315
316private:
317 // variables
318 QXmlContentHandler *contentHnd;
319 QXmlErrorHandler *errorHnd;
320 QXmlDTDHandler *dtdHnd;
321 QXmlEntityResolver *entityRes;
322 QXmlLexicalHandler *lexicalHnd;
323 QXmlDeclHandler *declHnd;
324
325 QXmlInputSource *inputSource;
326
327 QChar c; // the character at reading position
328 int lineNr; // number of line
329 int columnNr; // position in line
330
331 int nameArrayPos;
332 QChar nameArray[256]; // only used for names
333 QString nameValue; // only used for names
334 int refArrayPos;
335 QChar refArray[256]; // only used for references
336 QString refValue; // only used for references
337 int stringArrayPos;
338 QChar stringArray[256]; // used for any other strings that are parsed
339 QString stringValue; // used for any other strings that are parsed
340
341 QXmlSimpleReaderPrivate* d;
342
343 const QString &amp;string();
344 void stringClear();
345 inline void stringAddC() { stringAddC(c); }
346 void stringAddC(const QChar&amp;);
347 const QString&amp; name();
348 void nameClear();
349 inline void nameAddC() { nameAddC(c); }
350 void nameAddC(const QChar&amp;);
351 const QString&amp; ref();
352 void refClear();
353 inline void refAddC() { refAddC(c); }
354 void refAddC(const QChar&amp;);
355
356 // used by parseReference() and parsePEReference()
357 enum EntityRecognitionContext { InContent, InAttributeValue, InEntityValue, InDTD };
358
359 // private functions
360 bool eat_ws();
361 bool next_eat_ws();
362
363 void next();
364 bool atEnd();
365
366 void init( const QXmlInputSource* i );
367 void initData();
368
369 bool entityExist( const QString&amp; ) const;
370
371 bool parseBeginOrContinue( int state, bool incremental );
372
373 bool parseProlog();
374 bool parseElement();
375 bool processElementEmptyTag();
376 bool processElementETagBegin2();
377 bool processElementAttribute();
378 bool parseMisc();
379 bool parseContent();
380
381 bool parsePI();
382 bool parseDoctype();
383 bool parseComment();
384
385 bool parseName();
386 bool parseNmtoken();
387 bool parseAttribute();
388 bool parseReference();
389 bool processReference();
390
391 bool parseExternalID();
392 bool parsePEReference();
393 bool parseMarkupdecl();
394 bool parseAttlistDecl();
395 bool parseAttType();
396 bool parseAttValue();
397 bool parseElementDecl();
398 bool parseNotationDecl();
399 bool parseChoiceSeq();
400 bool parseEntityDecl();
401 bool parseEntityValue();
402
403 bool parseString();
404
405 bool insertXmlRef( const QString&amp;, const QString&amp;, bool );
406
407 bool reportEndEntities();
408 void reportParseError( const QString&amp; error );
409
410 typedef bool (QXmlSimpleReader::*ParseFunction) ();
411 void unexpectedEof( ParseFunction where, int state );
412 void parseFailed( ParseFunction where, int state );
413 void pushParseState( ParseFunction function, int state );
414
415 void setUndefEntityInAttrHack(bool b);
416
417 friend class QXmlSimpleReaderPrivate;
418 friend class QXmlSimpleReaderLocator;
419 friend class QDomDocumentPrivate;
420};
421
422//
423// SAX Locator
424//
425
426class QM_EXPORT_XML QXmlLocator
427{
428public:
429 QXmlLocator();
430 virtual ~QXmlLocator();
431
432 virtual int columnNumber() = 0;
433 virtual int lineNumber() = 0;
434// QString getPublicId()
435// QString getSystemId()
436};
437
438//
439// SAX handler classes
440//
441
442class QM_EXPORT_XML QXmlContentHandler
443{
444public:
445 virtual void setDocumentLocator( QXmlLocator* locator ) = 0;
446 virtual bool startDocument() = 0;
447 virtual bool endDocument() = 0;
448 virtual bool startPrefixMapping( const QString&amp; prefix, const QString&amp; uri ) = 0;
449 virtual bool endPrefixMapping( const QString&amp; prefix ) = 0;
450 virtual bool startElement( const QString&amp; namespaceURI, const QString&amp; localName, const QString&amp; qName, const QXmlAttributes&amp; atts ) = 0;
451 virtual bool endElement( const QString&amp; namespaceURI, const QString&amp; localName, const QString&amp; qName ) = 0;
452 virtual bool characters( const QString&amp; ch ) = 0;
453 virtual bool ignorableWhitespace( const QString&amp; ch ) = 0;
454 virtual bool processingInstruction( const QString&amp; target, const QString&amp; data ) = 0;
455 virtual bool skippedEntity( const QString&amp; name ) = 0;
456 virtual QString errorString() = 0;
457};
458
459class QM_EXPORT_XML QXmlErrorHandler
460{
461public:
462 virtual bool warning( const QXmlParseException&amp; exception ) = 0;
463 virtual bool error( const QXmlParseException&amp; exception ) = 0;
464 virtual bool fatalError( const QXmlParseException&amp; exception ) = 0;
465 virtual QString errorString() = 0;
466};
467
468class QM_EXPORT_XML QXmlDTDHandler
469{
470public:
471 virtual bool notationDecl( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId ) = 0;
472 virtual bool unparsedEntityDecl( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId, const QString&amp; notationName ) = 0;
473 virtual QString errorString() = 0;
474};
475
476class QM_EXPORT_XML QXmlEntityResolver
477{
478public:
479 virtual bool resolveEntity( const QString&amp; publicId, const QString&amp; systemId, QXmlInputSource*&amp; ret ) = 0;
480 virtual QString errorString() = 0;
481};
482
483class QM_EXPORT_XML QXmlLexicalHandler
484{
485public:
486 virtual bool startDTD( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId ) = 0;
487 virtual bool endDTD() = 0;
488 virtual bool startEntity( const QString&amp; name ) = 0;
489 virtual bool endEntity( const QString&amp; name ) = 0;
490 virtual bool startCDATA() = 0;
491 virtual bool endCDATA() = 0;
492 virtual bool comment( const QString&amp; ch ) = 0;
493 virtual QString errorString() = 0;
494};
495
496class QM_EXPORT_XML QXmlDeclHandler
497{
498public:
499 virtual bool attributeDecl( const QString&amp; eName, const QString&amp; aName, const QString&amp; type, const QString&amp; valueDefault, const QString&amp; value ) = 0;
500 virtual bool internalEntityDecl( const QString&amp; name, const QString&amp; value ) = 0;
501 virtual bool externalEntityDecl( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId ) = 0;
502 virtual QString errorString() = 0;
503};
504
505
506class QM_EXPORT_XML QXmlDefaultHandler : public QXmlContentHandler, public QXmlErrorHandler, public QXmlDTDHandler, public QXmlEntityResolver, public QXmlLexicalHandler, public QXmlDeclHandler
507{
508public:
509 QXmlDefaultHandler() { }
510 virtual ~QXmlDefaultHandler() { }
511
512 void setDocumentLocator( QXmlLocator* locator );
513 bool startDocument();
514 bool endDocument();
515 bool startPrefixMapping( const QString&amp; prefix, const QString&amp; uri );
516 bool endPrefixMapping( const QString&amp; prefix );
517 bool startElement( const QString&amp; namespaceURI, const QString&amp; localName, const QString&amp; qName, const QXmlAttributes&amp; atts );
518 bool endElement( const QString&amp; namespaceURI, const QString&amp; localName, const QString&amp; qName );
519 bool characters( const QString&amp; ch );
520 bool ignorableWhitespace( const QString&amp; ch );
521 bool processingInstruction( const QString&amp; target, const QString&amp; data );
522 bool skippedEntity( const QString&amp; name );
523
524 bool warning( const QXmlParseException&amp; exception );
525 bool error( const QXmlParseException&amp; exception );
526 bool fatalError( const QXmlParseException&amp; exception );
527
528 bool notationDecl( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId );
529 bool unparsedEntityDecl( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId, const QString&amp; notationName );
530
531 bool resolveEntity( const QString&amp; publicId, const QString&amp; systemId, QXmlInputSource*&amp; ret );
532
533 bool startDTD( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId );
534 bool endDTD();
535 bool startEntity( const QString&amp; name );
536 bool endEntity( const QString&amp; name );
537 bool startCDATA();
538 bool endCDATA();
539 bool comment( const QString&amp; ch );
540
541 bool attributeDecl( const QString&amp; eName, const QString&amp; aName, const QString&amp; type, const QString&amp; valueDefault, const QString&amp; value );
542 bool internalEntityDecl( const QString&amp; name, const QString&amp; value );
543 bool externalEntityDecl( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId );
544
545 QString errorString();
546
547private:
548 QXmlDefaultHandlerPrivate *d;
549};
550
551
552//
553// inlines
554//
555
556inline bool QXmlSimpleReader::atEnd()
557{ return (c.unicode()|0x0001) == 0xffff; }
558inline int QXmlAttributes::count() const
559{ return length(); }
560
561
562#endif //QT_NO_XML
563
564#endif
565</pre>
566<!-- eof -->
567<p><address><hr><div align=center>
568<table width=100% cellspacing=0 border=0><tr>
569<td>Copyright &copy; 2007
570<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
571<td align=right><div align=right>Qt 3.3.8</div>
572</table></div></address></body>
573</html>
Note: See TracBrowser for help on using the repository browser.