summaryrefslogtreecommitdiffstats
path: root/doc/html/qxml-h.html
blob: a0a535c1eea5904c2a1bf2f22b9923cd0b8d9a41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/include/qxml.h:1 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>qxml.h Include File</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<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>

<p>This is the verbatim text of the qxml.h include file. It is provided only for illustration; the copyright remains with Trolltech.
<hr>
<pre>
/****************************************************************************
** $Id: qt/qxml.h   3.3.8   edited Jan 11 14:39 $
**
** Definition of QXmlSimpleReader and related classes.
**
** Created : 000518
**
** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
**
** This file is part of the xml module of the Qt GUI Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Alternatively you may (at your option) use any
** later version of the GNU General Public License if such license has
** been publicly approved by Trolltech ASA (or its successors, if any)
** and the KDE Free Qt Foundation.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/.
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** This file may be used under the terms of the Q Public License as
** defined by Trolltech ASA and appearing in the file LICENSE.QPL
** included in the packaging of this file.  Licensees holding valid Qt
** Commercial licenses may use this file in accordance with the Qt
** Commercial License Agreement provided with the Software.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
** herein.
**
**********************************************************************/

#ifndef QXML_H
#define QXML_H

#ifndef QT_H
#include "qtextstream.h"
#include "qfile.h"
#include "qstring.h"
#include "qstringlist.h"
#include "qvaluevector.h"
#endif // QT_H

#if !defined(QT_MODULE_XML) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_XML )
#define QM_EXPORT_XML
#else
#define QM_EXPORT_XML Q_EXPORT
#endif

#ifndef QT_NO_XML

class QXmlNamespaceSupport;
class QXmlAttributes;
class QXmlContentHandler;
class QXmlDefaultHandler;
class QXmlDTDHandler;
class QXmlEntityResolver;
class QXmlErrorHandler;
class QXmlLexicalHandler;
class QXmlDeclHandler;
class QXmlInputSource;
class QXmlLocator;
class QXmlNamespaceSupport;
class QXmlParseException;

class QXmlReader;
class QXmlSimpleReader;

class QXmlSimpleReaderPrivate;
class QXmlNamespaceSupportPrivate;
class QXmlAttributesPrivate;
class QXmlInputSourcePrivate;
class QXmlParseExceptionPrivate;
class QXmlLocatorPrivate;
class QXmlDefaultHandlerPrivate;


//
// SAX Namespace Support
//

class QM_EXPORT_XML QXmlNamespaceSupport
{
public:
    QXmlNamespaceSupport();
    ~QXmlNamespaceSupport();

    void setPrefix( const QString&amp;, const QString&amp; );

    QString prefix( const QString&amp; ) const;
    QString uri( const QString&amp; ) const;
    void splitName( const QString&amp;, QString&amp;, QString&amp; ) const;
    void processName( const QString&amp;, bool, QString&amp;, QString&amp; ) const;
    QStringList prefixes() const;
    QStringList prefixes( const QString&amp; ) const;

    void pushContext();
    void popContext();
    void reset();

private:
    QXmlNamespaceSupportPrivate *d;

    friend class QXmlSimpleReader;
};


//
// SAX Attributes
//

class QM_EXPORT_XML QXmlAttributes
{
public:
    QXmlAttributes() {}
    virtual ~QXmlAttributes() {}

    int index( const QString&amp; qName ) const;
    int index( const QString&amp; uri, const QString&amp; localPart ) const;
    int length() const;
    int count() const;
    QString localName( int index ) const;
    QString qName( int index ) const;
    QString uri( int index ) const;
    QString type( int index ) const;
    QString type( const QString&amp; qName ) const;
    QString type( const QString&amp; uri, const QString&amp; localName ) const;
    QString value( int index ) const;
    QString value( const QString&amp; qName ) const;
    QString value( const QString&amp; uri, const QString&amp; localName ) const;

    void clear();
    void append( const QString &amp;qName, const QString &amp;uri, const QString &amp;localPart, const QString &amp;value );

private:
    QStringList qnameList;
    QStringList uriList;
    QStringList localnameList;
    QStringList valueList;

    QXmlAttributesPrivate *d;
};

//
// SAX Input Source
//

class QM_EXPORT_XML QXmlInputSource
{
public:
    QXmlInputSource();
    QXmlInputSource( QIODevice *dev );
    QXmlInputSource( QFile&amp; file ); // obsolete
    QXmlInputSource( QTextStream&amp; stream ); // obsolete
    virtual ~QXmlInputSource();

    virtual void setData( const QString&amp; dat );
    virtual void setData( const QByteArray&amp; dat );
    virtual void fetchData();
    virtual QString data();
    virtual QChar next();
    virtual void reset();

    static const QChar EndOfData;
    static const QChar EndOfDocument;

protected:
    virtual QString fromRawData( const QByteArray &amp;data, bool beginning = FALSE );

private:
    void init();

    QIODevice *inputDevice;
    QTextStream *inputStream;

    QString str;
    const QChar *unicode;
    int pos;
    int length;
    bool nextReturnedEndOfData;
    QTextDecoder *encMapper;

    QXmlInputSourcePrivate *d;
};

//
// SAX Exception Classes
//

class QM_EXPORT_XML QXmlParseException
{
public:
    QXmlParseException( const QString&amp; name="", int c=-1, int l=-1, const QString&amp; p="", const QString&amp; s="" )
	: msg( name ), column( c ), line( l ), pub( p ), sys( s )
    { }

    int columnNumber() const;
    int lineNumber() const;
    QString publicId() const;
    QString systemId() const;
    QString message() const;

private:
    QString msg;
    int column;
    int line;
    QString pub;
    QString sys;

    QXmlParseExceptionPrivate *d;
};


//
// XML Reader
//

class QM_EXPORT_XML QXmlReader
{
public:
    virtual bool feature( const QString&amp; name, bool *ok = 0 ) const = 0;
    virtual void setFeature( const QString&amp; name, bool value ) = 0;
    virtual bool hasFeature( const QString&amp; name ) const = 0;
    virtual void* property( const QString&amp; name, bool *ok = 0 ) const = 0;
    virtual void setProperty( const QString&amp; name, void* value ) = 0;
    virtual bool hasProperty( const QString&amp; name ) const = 0;
    virtual void setEntityResolver( QXmlEntityResolver* handler ) = 0;
    virtual QXmlEntityResolver* entityResolver() const = 0;
    virtual void setDTDHandler( QXmlDTDHandler* handler ) = 0;
    virtual QXmlDTDHandler* DTDHandler() const = 0;
    virtual void setContentHandler( QXmlContentHandler* handler ) = 0;
    virtual QXmlContentHandler* contentHandler() const = 0;
    virtual void setErrorHandler( QXmlErrorHandler* handler ) = 0;
    virtual QXmlErrorHandler* errorHandler() const = 0;
    virtual void setLexicalHandler( QXmlLexicalHandler* handler ) = 0;
    virtual QXmlLexicalHandler* lexicalHandler() const = 0;
    virtual void setDeclHandler( QXmlDeclHandler* handler ) = 0;
    virtual QXmlDeclHandler* declHandler() const = 0;
    virtual bool parse( const QXmlInputSource&amp; input ) = 0;
    virtual bool parse( const QXmlInputSource* input ) = 0;
};

class QM_EXPORT_XML QXmlSimpleReader : public QXmlReader
{
public:
    QXmlSimpleReader();
    virtual ~QXmlSimpleReader();

    bool feature( const QString&amp; name, bool *ok = 0 ) const;
    void setFeature( const QString&amp; name, bool value );
    bool hasFeature( const QString&amp; name ) const;

    void* property( const QString&amp; name, bool *ok = 0 ) const;
    void setProperty( const QString&amp; name, void* value );
    bool hasProperty( const QString&amp; name ) const;

    void setEntityResolver( QXmlEntityResolver* handler );
    QXmlEntityResolver* entityResolver() const;
    void setDTDHandler( QXmlDTDHandler* handler );
    QXmlDTDHandler* DTDHandler() const;
    void setContentHandler( QXmlContentHandler* handler );
    QXmlContentHandler* contentHandler() const;
    void setErrorHandler( QXmlErrorHandler* handler );
    QXmlErrorHandler* errorHandler() const;
    void setLexicalHandler( QXmlLexicalHandler* handler );
    QXmlLexicalHandler* lexicalHandler() const;
    void setDeclHandler( QXmlDeclHandler* handler );
    QXmlDeclHandler* declHandler() const;

    bool parse( const QXmlInputSource&amp; input );
    bool parse( const QXmlInputSource* input );
    virtual bool parse( const QXmlInputSource* input, bool incremental );
    virtual bool parseContinue();

private:
    // variables
    QXmlContentHandler *contentHnd;
    QXmlErrorHandler   *errorHnd;
    QXmlDTDHandler     *dtdHnd;
    QXmlEntityResolver *entityRes;
    QXmlLexicalHandler *lexicalHnd;
    QXmlDeclHandler    *declHnd;

    QXmlInputSource *inputSource;

    QChar c; // the character at reading position
    int   lineNr; // number of line
    int   columnNr; // position in line

    int     nameArrayPos;
    QChar   nameArray[256]; // only used for names
    QString nameValue; // only used for names
    int     refArrayPos;
    QChar   refArray[256]; // only used for references
    QString refValue; // only used for references
    int     stringArrayPos;
    QChar   stringArray[256]; // used for any other strings that are parsed
    QString stringValue; // used for any other strings that are parsed

    QXmlSimpleReaderPrivate* d;

    const QString &amp;string();
    void stringClear();
    inline void stringAddC() { stringAddC(c); }
    void stringAddC(const QChar&amp;);
    const QString&amp; name();
    void nameClear();
    inline void nameAddC() { nameAddC(c); }
    void nameAddC(const QChar&amp;);
    const QString&amp; ref();
    void refClear();
    inline void refAddC() { refAddC(c); }
    void refAddC(const QChar&amp;);

    // used by parseReference() and parsePEReference()
    enum EntityRecognitionContext { InContent, InAttributeValue, InEntityValue, InDTD };

    // private functions
    bool eat_ws();
    bool next_eat_ws();

    void next();
    bool atEnd();

    void init( const QXmlInputSource* i );
    void initData();

    bool entityExist( const QString&amp; ) const;

    bool parseBeginOrContinue( int state, bool incremental );

    bool parseProlog();
    bool parseElement();
    bool processElementEmptyTag();
    bool processElementETagBegin2();
    bool processElementAttribute();
    bool parseMisc();
    bool parseContent();

    bool parsePI();
    bool parseDoctype();
    bool parseComment();

    bool parseName();
    bool parseNmtoken();
    bool parseAttribute();
    bool parseReference();
    bool processReference();

    bool parseExternalID();
    bool parsePEReference();
    bool parseMarkupdecl();
    bool parseAttlistDecl();
    bool parseAttType();
    bool parseAttValue();
    bool parseElementDecl();
    bool parseNotationDecl();
    bool parseChoiceSeq();
    bool parseEntityDecl();
    bool parseEntityValue();

    bool parseString();

    bool insertXmlRef( const QString&amp;, const QString&amp;, bool );

    bool reportEndEntities();
    void reportParseError( const QString&amp; error );

    typedef bool (QXmlSimpleReader::*ParseFunction) ();
    void unexpectedEof( ParseFunction where, int state );
    void parseFailed( ParseFunction where, int state );
    void pushParseState( ParseFunction function, int state );

    void setUndefEntityInAttrHack(bool b);

    friend class QXmlSimpleReaderPrivate;
    friend class QXmlSimpleReaderLocator;
    friend class QDomDocumentPrivate;
};

//
// SAX Locator
//

class QM_EXPORT_XML QXmlLocator
{
public:
    QXmlLocator();
    virtual ~QXmlLocator();

    virtual int columnNumber() = 0;
    virtual int lineNumber() = 0;
//    QString getPublicId()
//    QString getSystemId()
};

//
// SAX handler classes
//

class QM_EXPORT_XML QXmlContentHandler
{
public:
    virtual void setDocumentLocator( QXmlLocator* locator ) = 0;
    virtual bool startDocument() = 0;
    virtual bool endDocument() = 0;
    virtual bool startPrefixMapping( const QString&amp; prefix, const QString&amp; uri ) = 0;
    virtual bool endPrefixMapping( const QString&amp; prefix ) = 0;
    virtual bool startElement( const QString&amp; namespaceURI, const QString&amp; localName, const QString&amp; qName, const QXmlAttributes&amp; atts ) = 0;
    virtual bool endElement( const QString&amp; namespaceURI, const QString&amp; localName, const QString&amp; qName ) = 0;
    virtual bool characters( const QString&amp; ch ) = 0;
    virtual bool ignorableWhitespace( const QString&amp; ch ) = 0;
    virtual bool processingInstruction( const QString&amp; target, const QString&amp; data ) = 0;
    virtual bool skippedEntity( const QString&amp; name ) = 0;
    virtual QString errorString() = 0;
};

class QM_EXPORT_XML QXmlErrorHandler
{
public:
    virtual bool warning( const QXmlParseException&amp; exception ) = 0;
    virtual bool error( const QXmlParseException&amp; exception ) = 0;
    virtual bool fatalError( const QXmlParseException&amp; exception ) = 0;
    virtual QString errorString() = 0;
};

class QM_EXPORT_XML QXmlDTDHandler
{
public:
    virtual bool notationDecl( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId ) = 0;
    virtual bool unparsedEntityDecl( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId, const QString&amp; notationName ) = 0;
    virtual QString errorString() = 0;
};

class QM_EXPORT_XML QXmlEntityResolver
{
public:
    virtual bool resolveEntity( const QString&amp; publicId, const QString&amp; systemId, QXmlInputSource*&amp; ret ) = 0;
    virtual QString errorString() = 0;
};

class QM_EXPORT_XML QXmlLexicalHandler
{
public:
    virtual bool startDTD( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId ) = 0;
    virtual bool endDTD() = 0;
    virtual bool startEntity( const QString&amp; name ) = 0;
    virtual bool endEntity( const QString&amp; name ) = 0;
    virtual bool startCDATA() = 0;
    virtual bool endCDATA() = 0;
    virtual bool comment( const QString&amp; ch ) = 0;
    virtual QString errorString() = 0;
};

class QM_EXPORT_XML QXmlDeclHandler
{
public:
    virtual bool attributeDecl( const QString&amp; eName, const QString&amp; aName, const QString&amp; type, const QString&amp; valueDefault, const QString&amp; value ) = 0;
    virtual bool internalEntityDecl( const QString&amp; name, const QString&amp; value ) = 0;
    virtual bool externalEntityDecl( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId ) = 0;
    virtual QString errorString() = 0;
};


class QM_EXPORT_XML QXmlDefaultHandler : public QXmlContentHandler, public QXmlErrorHandler, public QXmlDTDHandler, public QXmlEntityResolver, public QXmlLexicalHandler, public QXmlDeclHandler
{
public:
    QXmlDefaultHandler() { }
    virtual ~QXmlDefaultHandler() { }

    void setDocumentLocator( QXmlLocator* locator );
    bool startDocument();
    bool endDocument();
    bool startPrefixMapping( const QString&amp; prefix, const QString&amp; uri );
    bool endPrefixMapping( const QString&amp; prefix );
    bool startElement( const QString&amp; namespaceURI, const QString&amp; localName, const QString&amp; qName, const QXmlAttributes&amp; atts );
    bool endElement( const QString&amp; namespaceURI, const QString&amp; localName, const QString&amp; qName );
    bool characters( const QString&amp; ch );
    bool ignorableWhitespace( const QString&amp; ch );
    bool processingInstruction( const QString&amp; target, const QString&amp; data );
    bool skippedEntity( const QString&amp; name );

    bool warning( const QXmlParseException&amp; exception );
    bool error( const QXmlParseException&amp; exception );
    bool fatalError( const QXmlParseException&amp; exception );

    bool notationDecl( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId );
    bool unparsedEntityDecl( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId, const QString&amp; notationName );

    bool resolveEntity( const QString&amp; publicId, const QString&amp; systemId, QXmlInputSource*&amp; ret );

    bool startDTD( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId );
    bool endDTD();
    bool startEntity( const QString&amp; name );
    bool endEntity( const QString&amp; name );
    bool startCDATA();
    bool endCDATA();
    bool comment( const QString&amp; ch );

    bool attributeDecl( const QString&amp; eName, const QString&amp; aName, const QString&amp; type, const QString&amp; valueDefault, const QString&amp; value );
    bool internalEntityDecl( const QString&amp; name, const QString&amp; value );
    bool externalEntityDecl( const QString&amp; name, const QString&amp; publicId, const QString&amp; systemId );

    QString errorString();

private:
    QXmlDefaultHandlerPrivate *d;
};


//
// inlines
//

inline bool QXmlSimpleReader::atEnd()
{ return (c.unicode()|0x0001) == 0xffff; }
inline int QXmlAttributes::count() const
{ return length(); }


#endif //QT_NO_XML

#endif
</pre>
<!-- eof -->
<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>