-rw-r--r-- | qtcompat/xml/qxml.h | 674 |
1 files changed, 674 insertions, 0 deletions
diff --git a/qtcompat/xml/qxml.h b/qtcompat/xml/qxml.h new file mode 100644 index 0000000..b772df9 --- a/dev/null +++ b/qtcompat/xml/qxml.h | |||
@@ -0,0 +1,674 @@ | |||
1 | /**************************************************************************** | ||
2 | ** $Id$ | ||
3 | ** | ||
4 | ** Definition of QXmlSimpleReader and related classes. | ||
5 | ** | ||
6 | ** Created : 000518 | ||
7 | ** | ||
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | ||
9 | ** | ||
10 | ** This file is part of the XML module of the Qt GUI Toolkit. | ||
11 | ** | ||
12 | ** This file may be distributed under the terms of the Q Public License | ||
13 | ** as defined by Trolltech AS of Norway and appearing in the file | ||
14 | ** LICENSE.QPL included in the packaging of this file. | ||
15 | ** | ||
16 | ** This file may be distributed and/or modified under the terms of the | ||
17 | ** GNU General Public License version 2 as published by the Free Software | ||
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
19 | ** packaging of this file. | ||
20 | ** | ||
21 | ** Licensees holding valid Qt Enterprise Edition licenses may use this | ||
22 | ** file in accordance with the Qt Commercial License Agreement provided | ||
23 | ** with the Software. | ||
24 | ** | ||
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
27 | ** | ||
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | ||
29 | ** information about Qt Commercial License Agreements. | ||
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | ||
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
32 | ** | ||
33 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
34 | ** not clear to you. | ||
35 | ** | ||
36 | **********************************************************************/ | ||
37 | |||
38 | |||
39 | /****************************************** | ||
40 | * DOM support is disabled in QT 2.3.7 for sharp zaurus. | ||
41 | * Because of that we copied the code from 2.3.7 into qtcompat and enabled it | ||
42 | * there. | ||
43 | * Copyright (c) 2004 Ulf Schenk | ||
44 | * | ||
45 | * $Id$ | ||
46 | ******************************************/ | ||
47 | |||
48 | #ifndef QXML_H | ||
49 | #define QXML_H | ||
50 | |||
51 | #include <qmodules.h> | ||
52 | |||
53 | //US #if !defined(QT_MODULE_XML) | ||
54 | //US #define QM_EXPORT | ||
55 | //US #else | ||
56 | #define QM_EXPORT Q_EXPORT | ||
57 | //US #endif | ||
58 | |||
59 | #ifndef QT_H | ||
60 | #include <qtextstream.h> | ||
61 | #include <qfile.h> | ||
62 | #include <qstring.h> | ||
63 | #include <qstringlist.h> | ||
64 | #include <qvaluestack.h> | ||
65 | #include <qmap.h> | ||
66 | #endif // QT_H | ||
67 | |||
68 | //US #ifndef QT_NO_XML | ||
69 | |||
70 | class QXmlNamespaceSupport; | ||
71 | class QXmlAttributes; | ||
72 | class QXmlContentHandler; | ||
73 | class QXmlDefaultHandler; | ||
74 | class QXmlDTDHandler; | ||
75 | class QXmlEntityResolver; | ||
76 | class QXmlErrorHandler; | ||
77 | class QXmlLexicalHandler; | ||
78 | class QXmlDeclHandler; | ||
79 | class QXmlInputSource; | ||
80 | class QXmlLocator; | ||
81 | class QXmlNamespaceSupport; | ||
82 | class QXmlParseException; | ||
83 | |||
84 | class QXmlReader; | ||
85 | class QXmlSimpleReader; | ||
86 | |||
87 | class QXmlSimpleReaderPrivate; | ||
88 | class QXmlNamespaceSupportPrivate; | ||
89 | class QXmlAttributesPrivate; | ||
90 | class QXmlInputSourcePrivate; | ||
91 | class QXmlParseExceptionPrivate; | ||
92 | class QXmlLocatorPrivate; | ||
93 | class QXmlDefaultHandlerPrivate; | ||
94 | |||
95 | |||
96 | // | ||
97 | // SAX Namespace Support | ||
98 | // | ||
99 | |||
100 | #if defined(Q_TEMPLATEDLL) | ||
101 | // MOC_SKIP_BEGIN | ||
102 | template class QM_EXPORT QMap<QString, QString>; | ||
103 | template class QM_EXPORT QValueStack<QMap<QString, QString> >; | ||
104 | template class QM_EXPORT QValueStack<QString>; | ||
105 | // MOC_SKIP_END | ||
106 | #endif | ||
107 | |||
108 | class QM_EXPORT QXmlNamespaceSupport | ||
109 | { | ||
110 | public: | ||
111 | QXmlNamespaceSupport(); | ||
112 | ~QXmlNamespaceSupport(); | ||
113 | |||
114 | void setPrefix( const QString&, const QString& ); | ||
115 | |||
116 | QString prefix( const QString& ) const; | ||
117 | QString uri( const QString& ) const; | ||
118 | void splitName( const QString&, QString&, QString& ) const; | ||
119 | void processName( const QString&, bool, QString&, QString& ) const; | ||
120 | QStringList prefixes() const; | ||
121 | QStringList prefixes( const QString& ) const; | ||
122 | |||
123 | void pushContext(); | ||
124 | void popContext(); | ||
125 | void reset(); | ||
126 | private: | ||
127 | QValueStack<QMap<QString, QString> > nsStack; | ||
128 | QMap<QString, QString> ns; | ||
129 | |||
130 | QXmlNamespaceSupportPrivate *d; | ||
131 | }; | ||
132 | |||
133 | |||
134 | // | ||
135 | // SAX Attributes | ||
136 | // | ||
137 | |||
138 | class QM_EXPORT QXmlAttributes | ||
139 | { | ||
140 | public: | ||
141 | QXmlAttributes() {} | ||
142 | virtual ~QXmlAttributes() {} | ||
143 | |||
144 | int index( const QString& qName ) const; | ||
145 | int index( const QString& uri, const QString& localPart ) const; | ||
146 | int length() const; | ||
147 | QString localName( int index ) const; | ||
148 | QString qName( int index ) const; | ||
149 | QString uri( int index ) const; | ||
150 | QString type( int index ) const; | ||
151 | QString type( const QString& qName ) const; | ||
152 | QString type( const QString& uri, const QString& localName ) const; | ||
153 | QString value( int index ) const; | ||
154 | QString value( const QString& qName ) const; | ||
155 | QString value( const QString& uri, const QString& localName ) const; | ||
156 | |||
157 | private: | ||
158 | QStringList qnameList; | ||
159 | QStringList uriList; | ||
160 | QStringList localnameList; | ||
161 | QStringList valueList; | ||
162 | |||
163 | QXmlAttributesPrivate *d; | ||
164 | |||
165 | friend class QXmlSimpleReader; | ||
166 | }; | ||
167 | |||
168 | // | ||
169 | // SAX Input Source | ||
170 | // | ||
171 | |||
172 | class QM_EXPORT QXmlInputSource | ||
173 | { | ||
174 | public: | ||
175 | QXmlInputSource(); | ||
176 | QXmlInputSource( QTextStream& stream ); | ||
177 | QXmlInputSource( QFile& file ); | ||
178 | virtual ~QXmlInputSource(); | ||
179 | |||
180 | virtual const QString& data() const; | ||
181 | virtual void setData( const QString& d ); | ||
182 | |||
183 | private: | ||
184 | void readInput( QByteArray& rawData ); | ||
185 | |||
186 | QString input; | ||
187 | |||
188 | QXmlInputSourcePrivate *d; | ||
189 | }; | ||
190 | |||
191 | // | ||
192 | // SAX Exception Classes | ||
193 | // | ||
194 | |||
195 | class QM_EXPORT QXmlParseException | ||
196 | { | ||
197 | public: | ||
198 | QXmlParseException( const QString& name="", int c=-1, int l=-1, const QString& p="", const QString& s="" ) | ||
199 | : msg( name ), column( c ), line( l ), pub( p ), sys( s ) | ||
200 | { } | ||
201 | |||
202 | int columnNumber() const; | ||
203 | int lineNumber() const; | ||
204 | QString publicId() const; | ||
205 | QString systemId() const; | ||
206 | QString message() const; | ||
207 | |||
208 | private: | ||
209 | QString msg; | ||
210 | int column; | ||
211 | int line; | ||
212 | QString pub; | ||
213 | QString sys; | ||
214 | |||
215 | QXmlParseExceptionPrivate *d; | ||
216 | }; | ||
217 | |||
218 | |||
219 | // | ||
220 | // XML Reader | ||
221 | // | ||
222 | |||
223 | class QM_EXPORT QXmlReader | ||
224 | { | ||
225 | public: | ||
226 | virtual bool feature( const QString& name, bool *ok = 0 ) const = 0; | ||
227 | virtual void setFeature( const QString& name, bool value ) = 0; | ||
228 | virtual bool hasFeature( const QString& name ) const = 0; | ||
229 | virtual void* property( const QString& name, bool *ok = 0 ) const = 0; | ||
230 | virtual void setProperty( const QString& name, void* value ) = 0; | ||
231 | virtual bool hasProperty( const QString& name ) const = 0; | ||
232 | virtual void setEntityResolver( QXmlEntityResolver* handler ) = 0; | ||
233 | virtual QXmlEntityResolver* entityResolver() const = 0; | ||
234 | virtual void setDTDHandler( QXmlDTDHandler* handler ) = 0; | ||
235 | virtual QXmlDTDHandler* DTDHandler() const = 0; | ||
236 | virtual void setContentHandler( QXmlContentHandler* handler ) = 0; | ||
237 | virtual QXmlContentHandler* contentHandler() const = 0; | ||
238 | virtual void setErrorHandler( QXmlErrorHandler* handler ) = 0; | ||
239 | virtual QXmlErrorHandler* errorHandler() const = 0; | ||
240 | virtual void setLexicalHandler( QXmlLexicalHandler* handler ) = 0; | ||
241 | virtual QXmlLexicalHandler* lexicalHandler() const = 0; | ||
242 | virtual void setDeclHandler( QXmlDeclHandler* handler ) = 0; | ||
243 | virtual QXmlDeclHandler* declHandler() const = 0; | ||
244 | virtual bool parse( const QXmlInputSource& input ) = 0; | ||
245 | }; | ||
246 | |||
247 | class QM_EXPORT QXmlSimpleReader : public QXmlReader | ||
248 | { | ||
249 | public: | ||
250 | QXmlSimpleReader(); | ||
251 | virtual ~QXmlSimpleReader(); | ||
252 | |||
253 | bool feature( const QString& name, bool *ok = 0 ) const; | ||
254 | void setFeature( const QString& name, bool value ); | ||
255 | bool hasFeature( const QString& name ) const; | ||
256 | |||
257 | void* property( const QString& name, bool *ok = 0 ) const; | ||
258 | void setProperty( const QString& name, void* value ); | ||
259 | bool hasProperty( const QString& name ) const; | ||
260 | |||
261 | void setEntityResolver( QXmlEntityResolver* handler ); | ||
262 | QXmlEntityResolver* entityResolver() const; | ||
263 | void setDTDHandler( QXmlDTDHandler* handler ); | ||
264 | QXmlDTDHandler* DTDHandler() const; | ||
265 | void setContentHandler( QXmlContentHandler* handler ); | ||
266 | QXmlContentHandler* contentHandler() const; | ||
267 | void setErrorHandler( QXmlErrorHandler* handler ); | ||
268 | QXmlErrorHandler* errorHandler() const; | ||
269 | void setLexicalHandler( QXmlLexicalHandler* handler ); | ||
270 | QXmlLexicalHandler* lexicalHandler() const; | ||
271 | void setDeclHandler( QXmlDeclHandler* handler ); | ||
272 | QXmlDeclHandler* declHandler() const; | ||
273 | |||
274 | bool parse( const QXmlInputSource& input ); | ||
275 | |||
276 | private: | ||
277 | // variables | ||
278 | QXmlContentHandler* contentHnd; | ||
279 | QXmlErrorHandler* errorHnd; | ||
280 | QXmlDTDHandler* dtdHnd; | ||
281 | QXmlEntityResolver* entityRes; | ||
282 | QXmlLexicalHandler* lexicalHnd; | ||
283 | QXmlDeclHandler* declHnd; | ||
284 | |||
285 | QChar c; // the character at reading position | ||
286 | int lineNr; // number of line | ||
287 | int columnNr; // position in line | ||
288 | int pos; // position in string | ||
289 | |||
290 | int namePos; | ||
291 | QChar nameArray[256]; // only used for names | ||
292 | QString nameValue; // only used for names | ||
293 | int refPos; | ||
294 | QChar refArray[256]; // only used for references | ||
295 | QString refValue; // only used for references | ||
296 | int stringPos; | ||
297 | QChar stringArray[256]; // used for any other strings that are parsed | ||
298 | QString stringValue; // used for any other strings that are parsed | ||
299 | |||
300 | QString xml; | ||
301 | int xmlLength; | ||
302 | QString xmlRef; // used for parsing of entity references | ||
303 | |||
304 | QValueStack<QString> tags; | ||
305 | |||
306 | QXmlSimpleReaderPrivate* d; | ||
307 | |||
308 | static const QChar QEOF; | ||
309 | |||
310 | // inlines | ||
311 | virtual bool is_S( const QChar& ); | ||
312 | virtual bool is_Letter( const QChar& ); | ||
313 | virtual bool is_NameBeginning( const QChar& ); | ||
314 | virtual bool is_Digit( const QChar& ); | ||
315 | virtual bool is_CombiningChar( const QChar& ); | ||
316 | virtual bool is_Extender( const QChar& ); | ||
317 | virtual bool is_NameChar( const QChar& ); | ||
318 | |||
319 | QString& string(); | ||
320 | void stringClear(); | ||
321 | void stringAddC(); | ||
322 | void stringAddC(const QChar&); | ||
323 | QString& name(); | ||
324 | void nameClear(); | ||
325 | void nameAddC(); | ||
326 | void nameAddC(const QChar&); | ||
327 | QString& ref(); | ||
328 | void refClear(); | ||
329 | void refAddC(); | ||
330 | void refAddC(const QChar&); | ||
331 | |||
332 | // used by parseReference() and parsePEReference() | ||
333 | enum EntityRecognitionContext { InContent, InAttributeValue, InEntityValue, InDTD }; | ||
334 | |||
335 | // private functions | ||
336 | void eat_ws(); | ||
337 | void next_eat_ws(); | ||
338 | |||
339 | void next(); | ||
340 | bool atEnd(); | ||
341 | |||
342 | void init( const QXmlInputSource& i ); | ||
343 | |||
344 | bool entityExist( const QString& ) const; | ||
345 | |||
346 | bool parseProlog(); | ||
347 | bool parseElement(); | ||
348 | bool parseElementEmptyTag( bool &t, QString &uri, QString &lname ); | ||
349 | bool parseElementETagBegin2(); | ||
350 | bool parseElementAttribute( QString &prefix, QString &uri, QString &lname ); | ||
351 | bool parseMisc(); | ||
352 | bool parseContent(); | ||
353 | |||
354 | bool parsePI(bool xmldecl=FALSE); | ||
355 | bool parseDoctype(); | ||
356 | bool parseComment(); | ||
357 | |||
358 | bool parseName( bool useRef=FALSE ); | ||
359 | bool parseNmtoken(); | ||
360 | bool parseAttribute(); | ||
361 | bool parseReference( bool &charDataRead, EntityRecognitionContext context ); | ||
362 | bool processReference( bool &charDataRead, EntityRecognitionContext context ); | ||
363 | |||
364 | bool parseExternalID( bool allowPublicID = FALSE ); | ||
365 | bool parsePEReference( EntityRecognitionContext context ); | ||
366 | bool parseMarkupdecl(); | ||
367 | bool parseAttlistDecl(); | ||
368 | bool parseAttType(); | ||
369 | bool parseAttValue(); | ||
370 | bool parseElementDecl(); | ||
371 | bool parseNotationDecl(); | ||
372 | bool parseChoiceSeq(); | ||
373 | bool parseEntityDecl(); | ||
374 | bool parseEntityValue(); | ||
375 | |||
376 | bool parseString( const QString& s ); | ||
377 | |||
378 | void reportParseError(); | ||
379 | |||
380 | friend class QXmlSimpleReaderPrivate; | ||
381 | friend class QXmlLocator; | ||
382 | }; | ||
383 | |||
384 | // | ||
385 | // SAX Locator | ||
386 | // | ||
387 | |||
388 | class QM_EXPORT QXmlLocator | ||
389 | { | ||
390 | public: | ||
391 | QXmlLocator( QXmlSimpleReader* parent ) | ||
392 | { reader = parent; } | ||
393 | ~QXmlLocator() | ||
394 | { } | ||
395 | |||
396 | int columnNumber(); | ||
397 | int lineNumber(); | ||
398 | // QString getPublicId() | ||
399 | // QString getSystemId() | ||
400 | |||
401 | private: | ||
402 | QXmlSimpleReader* reader; | ||
403 | |||
404 | QXmlLocatorPrivate *d; | ||
405 | }; | ||
406 | |||
407 | // | ||
408 | // SAX handler classes | ||
409 | // | ||
410 | |||
411 | class QM_EXPORT QXmlContentHandler | ||
412 | { | ||
413 | public: | ||
414 | virtual void setDocumentLocator( QXmlLocator* locator ) = 0; | ||
415 | virtual bool startDocument() = 0; | ||
416 | virtual bool endDocument() = 0; | ||
417 | virtual bool startPrefixMapping( const QString& prefix, const QString& uri ) = 0; | ||
418 | virtual bool endPrefixMapping( const QString& prefix ) = 0; | ||
419 | virtual bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ) = 0; | ||
420 | virtual bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ) = 0; | ||
421 | virtual bool characters( const QString& ch ) = 0; | ||
422 | virtual bool ignorableWhitespace( const QString& ch ) = 0; | ||
423 | virtual bool processingInstruction( const QString& target, const QString& data ) = 0; | ||
424 | virtual bool skippedEntity( const QString& name ) = 0; | ||
425 | virtual QString errorString() = 0; | ||
426 | }; | ||
427 | |||
428 | class QM_EXPORT QXmlErrorHandler | ||
429 | { | ||
430 | public: | ||
431 | virtual bool warning( const QXmlParseException& exception ) = 0; | ||
432 | virtual bool error( const QXmlParseException& exception ) = 0; | ||
433 | virtual bool fatalError( const QXmlParseException& exception ) = 0; | ||
434 | virtual QString errorString() = 0; | ||
435 | }; | ||
436 | |||
437 | class QM_EXPORT QXmlDTDHandler | ||
438 | { | ||
439 | public: | ||
440 | virtual bool notationDecl( const QString& name, const QString& publicId, const QString& systemId ) = 0; | ||
441 | virtual bool unparsedEntityDecl( const QString& name, const QString& publicId, const QString& systemId, const QString& notationName ) = 0; | ||
442 | virtual QString errorString() = 0; | ||
443 | }; | ||
444 | |||
445 | class QM_EXPORT QXmlEntityResolver | ||
446 | { | ||
447 | public: | ||
448 | virtual bool resolveEntity( const QString& publicId, const QString& systemId, QXmlInputSource* ret ) = 0; | ||
449 | virtual QString errorString() = 0; | ||
450 | }; | ||
451 | |||
452 | class QM_EXPORT QXmlLexicalHandler | ||
453 | { | ||
454 | public: | ||
455 | virtual bool startDTD( const QString& name, const QString& publicId, const QString& systemId ) = 0; | ||
456 | virtual bool endDTD() = 0; | ||
457 | // virtual bool startEntity( const QString& name ) = 0; | ||
458 | // virtual bool endEntity( const QString& name ) = 0; | ||
459 | virtual bool startCDATA() = 0; | ||
460 | virtual bool endCDATA() = 0; | ||
461 | virtual bool comment( const QString& ch ) = 0; | ||
462 | virtual QString errorString() = 0; | ||
463 | }; | ||
464 | |||
465 | class QM_EXPORT QXmlDeclHandler | ||
466 | { | ||
467 | public: | ||
468 | virtual bool attributeDecl( const QString& eName, const QString& aName, const QString& type, const QString& valueDefault, const QString& value ) = 0; | ||
469 | virtual bool internalEntityDecl( const QString& name, const QString& value ) = 0; | ||
470 | virtual bool externalEntityDecl( const QString& name, const QString& publicId, const QString& systemId ) = 0; | ||
471 | virtual QString errorString() = 0; | ||
472 | }; | ||
473 | |||
474 | |||
475 | class QM_EXPORT QXmlDefaultHandler : public QXmlContentHandler, public QXmlErrorHandler, public QXmlDTDHandler, public QXmlEntityResolver, public QXmlLexicalHandler, public QXmlDeclHandler | ||
476 | { | ||
477 | public: | ||
478 | QXmlDefaultHandler() { } | ||
479 | virtual ~QXmlDefaultHandler() { } | ||
480 | |||
481 | void setDocumentLocator( QXmlLocator* locator ); | ||
482 | bool startDocument(); | ||
483 | bool endDocument(); | ||
484 | bool startPrefixMapping( const QString& prefix, const QString& uri ); | ||
485 | bool endPrefixMapping( const QString& prefix ); | ||
486 | bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); | ||
487 | bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); | ||
488 | bool characters( const QString& ch ); | ||
489 | bool ignorableWhitespace( const QString& ch ); | ||
490 | bool processingInstruction( const QString& target, const QString& data ); | ||
491 | bool skippedEntity( const QString& name ); | ||
492 | |||
493 | bool warning( const QXmlParseException& exception ); | ||
494 | bool error( const QXmlParseException& exception ); | ||
495 | bool fatalError( const QXmlParseException& exception ); | ||
496 | |||
497 | bool notationDecl( const QString& name, const QString& publicId, const QString& systemId ); | ||
498 | bool unparsedEntityDecl( const QString& name, const QString& publicId, const QString& systemId, const QString& notationName ); | ||
499 | |||
500 | bool resolveEntity( const QString& publicId, const QString& systemId, QXmlInputSource* ret ); | ||
501 | |||
502 | bool startDTD( const QString& name, const QString& publicId, const QString& systemId ); | ||
503 | bool endDTD(); | ||
504 | // bool startEntity( const QString& name ); | ||
505 | // bool endEntity( const QString& name ); | ||
506 | bool startCDATA(); | ||
507 | bool endCDATA(); | ||
508 | bool comment( const QString& ch ); | ||
509 | |||
510 | bool attributeDecl( const QString& eName, const QString& aName, const QString& type, const QString& valueDefault, const QString& value ); | ||
511 | bool internalEntityDecl( const QString& name, const QString& value ); | ||
512 | bool externalEntityDecl( const QString& name, const QString& publicId, const QString& systemId ); | ||
513 | |||
514 | QString errorString(); | ||
515 | |||
516 | private: | ||
517 | QXmlDefaultHandlerPrivate *d; | ||
518 | }; | ||
519 | |||
520 | #ifdef _WS_QWS_ | ||
521 | #ifdef QT_XML_CPP | ||
522 | #define inline | ||
523 | #else | ||
524 | #define QT_NO_XML_INLINE | ||
525 | #endif | ||
526 | #endif | ||
527 | |||
528 | #ifndef QT_NO_XML_INLINE | ||
529 | // | ||
530 | // inlines | ||
531 | // | ||
532 | |||
533 | inline bool QXmlSimpleReader::is_S(const QChar& ch) | ||
534 | { return ch==' ' || ch=='\t' || ch=='\n' || ch=='\r'; } | ||
535 | |||
536 | inline bool QXmlSimpleReader::is_Letter( const QChar& ch ) | ||
537 | { return ch.isLetter(); } | ||
538 | |||
539 | inline bool QXmlSimpleReader::is_NameBeginning( const QChar& ch ) | ||
540 | { return ch=='_' || ch==':' || ch.isLetter(); } | ||
541 | |||
542 | inline bool QXmlSimpleReader::is_Digit( const QChar& ch ) | ||
543 | { return ch.isDigit(); } | ||
544 | |||
545 | inline bool QXmlSimpleReader::is_CombiningChar( const QChar& ) | ||
546 | { return FALSE; } | ||
547 | |||
548 | inline bool QXmlSimpleReader::is_Extender( const QChar& ) | ||
549 | { return FALSE; } | ||
550 | |||
551 | inline bool QXmlSimpleReader::is_NameChar( const QChar& ch ) | ||
552 | { | ||
553 | return ch=='.' || ch=='-' || ch=='_' || ch==':' || | ||
554 | is_Letter(ch) || is_Digit(ch) || | ||
555 | is_CombiningChar(ch) || is_Extender(ch); | ||
556 | } | ||
557 | |||
558 | inline void QXmlSimpleReader::next() | ||
559 | { | ||
560 | if ( !xmlRef.isEmpty() ) { | ||
561 | c = xmlRef[0]; | ||
562 | xmlRef.remove( 0, 1 ); | ||
563 | } else { | ||
564 | if ( c=='\n' || c=='\r' ) { | ||
565 | lineNr++; | ||
566 | columnNr = -1; | ||
567 | } | ||
568 | if ( pos >= xmlLength ) { | ||
569 | c = QEOF; | ||
570 | } else { | ||
571 | c = xml[pos]; | ||
572 | columnNr++; | ||
573 | pos++; | ||
574 | } | ||
575 | } | ||
576 | } | ||
577 | |||
578 | inline bool QXmlSimpleReader::atEnd() | ||
579 | { return c == QEOF; } | ||
580 | |||
581 | inline void QXmlSimpleReader::eat_ws() | ||
582 | { while ( !atEnd() && is_S(c) ) next(); } | ||
583 | |||
584 | inline void QXmlSimpleReader::next_eat_ws() | ||
585 | { next(); eat_ws(); } | ||
586 | |||
587 | |||
588 | // use buffers instead of QString::operator+= when single characters are read | ||
589 | inline QString& QXmlSimpleReader::string() | ||
590 | { | ||
591 | stringValue += QString( stringArray, stringPos ); | ||
592 | stringPos = 0; | ||
593 | return stringValue; | ||
594 | } | ||
595 | inline QString& QXmlSimpleReader::name() | ||
596 | { | ||
597 | nameValue += QString( nameArray, namePos ); | ||
598 | namePos = 0; | ||
599 | return nameValue; | ||
600 | } | ||
601 | inline QString& QXmlSimpleReader::ref() | ||
602 | { | ||
603 | refValue += QString( refArray, refPos ); | ||
604 | refPos = 0; | ||
605 | return refValue; | ||
606 | } | ||
607 | |||
608 | inline void QXmlSimpleReader::stringClear() | ||
609 | { stringValue = ""; stringPos = 0; } | ||
610 | inline void QXmlSimpleReader::nameClear() | ||
611 | { nameValue = ""; namePos = 0; } | ||
612 | inline void QXmlSimpleReader::refClear() | ||
613 | { refValue = ""; refPos = 0; } | ||
614 | |||
615 | inline void QXmlSimpleReader::stringAddC() | ||
616 | { | ||
617 | if ( stringPos >= 256 ) { | ||
618 | stringValue += QString( stringArray, stringPos ); | ||
619 | stringPos = 0; | ||
620 | } | ||
621 | stringArray[stringPos++] = c; | ||
622 | } | ||
623 | inline void QXmlSimpleReader::nameAddC() | ||
624 | { | ||
625 | if ( namePos >= 256 ) { | ||
626 | nameValue += QString( nameArray, namePos ); | ||
627 | namePos = 0; | ||
628 | } | ||
629 | nameArray[namePos++] = c; | ||
630 | } | ||
631 | inline void QXmlSimpleReader::refAddC() | ||
632 | { | ||
633 | if ( refPos >= 256 ) { | ||
634 | refValue += QString( refArray, refPos ); | ||
635 | refPos = 0; | ||
636 | } | ||
637 | refArray[refPos++] = c; | ||
638 | } | ||
639 | |||
640 | inline void QXmlSimpleReader::stringAddC(const QChar& ch) | ||
641 | { | ||
642 | if ( stringPos >= 256 ) { | ||
643 | stringValue += QString( stringArray, stringPos ); | ||
644 | stringPos = 0; | ||
645 | } | ||
646 | stringArray[stringPos++] = ch; | ||
647 | } | ||
648 | inline void QXmlSimpleReader::nameAddC(const QChar& ch) | ||
649 | { | ||
650 | if ( namePos >= 256 ) { | ||
651 | nameValue += QString( nameArray, namePos ); | ||
652 | namePos = 0; | ||
653 | } | ||
654 | nameArray[namePos++] = ch; | ||
655 | } | ||
656 | inline void QXmlSimpleReader::refAddC(const QChar& ch) | ||
657 | { | ||
658 | if ( refPos >= 256 ) { | ||
659 | refValue += QString( refArray, refPos ); | ||
660 | refPos = 0; | ||
661 | } | ||
662 | refArray[refPos++] = ch; | ||
663 | } | ||
664 | #endif | ||
665 | |||
666 | #ifdef _WS_QWS_ | ||
667 | #ifdef QT_XML_CPP | ||
668 | #undef inline | ||
669 | #endif | ||
670 | #endif | ||
671 | |||
672 | //US #endif //QT_NO_XML | ||
673 | |||
674 | #endif | ||