Qt 4.8
Public Types | Public Functions | Properties | List of all members
QXmlStreamReader Class Reference

The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming API. More...

#include <qxmlstream.h>

Inheritance diagram for QXmlStreamReader:
QPatternist::MaintainingReader< XsdSchemaToken, XsdTagScope::Type > QPatternist::MaintainingReader< XSLTTokenLookup > QPatternist::MaintainingReader< TokenLookupClass, LookupKey > QPatternist::XsdSchemaParser QPatternist::XSLTTokenizer

Public Types

enum  Error {
  NoError, UnexpectedElementError, CustomError, NotWellFormedError,
  PrematureEndOfDocumentError
}
 This enum specifies different error cases. More...
 
enum  ReadElementTextBehaviour { ErrorOnUnexpectedElement, IncludeChildElements, SkipChildElements }
 This enum specifies the different behaviours of readElementText(). More...
 
enum  TokenType {
  NoToken = 0, Invalid, StartDocument, EndDocument,
  StartElement, EndElement, Characters, Comment,
  DTD, EntityReference, ProcessingInstruction
}
 This enum specifies the type of token the reader just read. More...
 

Public Functions

void addData (const QByteArray &data)
 Adds more data for the reader to read. More...
 
void addData (const QString &data)
 Adds more data for the reader to read. More...
 
void addData (const char *data)
 Adds more data for the reader to read. More...
 
void addExtraNamespaceDeclaration (const QXmlStreamNamespaceDeclaration &extraNamespaceDeclaraction)
 Adds an extraNamespaceDeclaration. More...
 
void addExtraNamespaceDeclarations (const QXmlStreamNamespaceDeclarations &extraNamespaceDeclaractions)
 Adds a vector of declarations specified by extraNamespaceDeclarations. More...
 
bool atEnd () const
 Returns true if the reader has read until the end of the XML document, or if an error() has occurred and reading has been aborted. More...
 
QXmlStreamAttributes attributes () const
 Returns the attributes of a StartElement. More...
 
qint64 characterOffset () const
 Returns the current character offset, starting with 0. More...
 
void clear ()
 Removes any device() or data from the reader and resets its internal state to the initial state. More...
 
qint64 columnNumber () const
 Returns the current column number, starting with 0. More...
 
QIODevicedevice () const
 Returns the current device associated with the QXmlStreamReader, or 0 if no device has been assigned. More...
 
QStringRef documentEncoding () const
 If the state() is StartDocument , this function returns the encoding string as specified in the XML declaration. More...
 
QStringRef documentVersion () const
 If the state() is StartDocument , this function returns the version string as specified in the XML declaration. More...
 
QStringRef dtdName () const
 If the state() is DTD , this function returns the DTD's name. More...
 
QStringRef dtdPublicId () const
 If the state() is DTD , this function returns the DTD's public identifier. More...
 
QStringRef dtdSystemId () const
 If the state() is DTD , this function returns the DTD's system identifier. More...
 
QXmlStreamEntityDeclarations entityDeclarations () const
 If the state() is DTD , this function returns the DTD's unparsed (external) entity declarations. More...
 
QXmlStreamEntityResolverentityResolver () const
 Returns the entity resolver, or 0 if there is no entity resolver. More...
 
Error error () const
 Returns the type of the current error, or NoError if no error occurred. More...
 
QString errorString () const
 Returns the error message that was set with raiseError(). More...
 
bool hasError () const
 Returns true if an error has occurred, otherwise false. More...
 
bool isCDATA () const
 Returns true if the reader reports characters that stem from a CDATA section; otherwise returns false. More...
 
bool isCharacters () const
 Returns true if tokenType() equals Characters ; otherwise returns false. More...
 
bool isComment () const
 Returns true if tokenType() equals Comment ; otherwise returns false. More...
 
bool isDTD () const
 Returns true if tokenType() equals DTD ; otherwise returns false. More...
 
bool isEndDocument () const
 Returns true if tokenType() equals EndDocument ; otherwise returns false. More...
 
bool isEndElement () const
 Returns true if tokenType() equals EndElement ; otherwise returns false. More...
 
bool isEntityReference () const
 Returns true if tokenType() equals EntityReference ; otherwise returns false. More...
 
bool isProcessingInstruction () const
 Returns true if tokenType() equals ProcessingInstruction ; otherwise returns false. More...
 
bool isStandaloneDocument () const
 Returns true if this document has been declared standalone in the XML declaration; otherwise returns false. More...
 
bool isStartDocument () const
 Returns true if tokenType() equals StartDocument ; otherwise returns false. More...
 
bool isStartElement () const
 Returns true if tokenType() equals StartElement ; otherwise returns false. More...
 
bool isWhitespace () const
 Returns true if the reader reports characters that only consist of white-space; otherwise returns false. More...
 
qint64 lineNumber () const
 Returns the current line number, starting with 1. More...
 
QStringRef name () const
 Returns the local name of a StartElement, EndElement, or an EntityReference. More...
 
QXmlStreamNamespaceDeclarations namespaceDeclarations () const
 If the state() is StartElement , this function returns the element's namespace declarations. More...
 
bool namespaceProcessing () const
 This property controls whether or not the stream reader processes namespaces. More...
 
QStringRef namespaceUri () const
 Returns the namespaceUri of a StartElement or EndElement. More...
 
QXmlStreamNotationDeclarations notationDeclarations () const
 If the state() is DTD , this function returns the DTD's notation declarations. More...
 
QStringRef prefix () const
 Returns the prefix of a StartElement or EndElement. More...
 
QStringRef processingInstructionData () const
 Returns the data of a ProcessingInstruction. More...
 
QStringRef processingInstructionTarget () const
 Returns the target of a ProcessingInstruction. More...
 
QStringRef qualifiedName () const
 Returns the qualified name of a StartElement or EndElement;. More...
 
 QXmlStreamReader ()
 Constructs a stream reader. More...
 
 QXmlStreamReader (QIODevice *device)
 Creates a new stream reader that reads from device. More...
 
 QXmlStreamReader (const QByteArray &data)
 Creates a new stream reader that reads from data. More...
 
 QXmlStreamReader (const QString &data)
 Creates a new stream reader that reads from data. More...
 
 QXmlStreamReader (const char *data)
 Creates a new stream reader that reads from data. More...
 
void raiseError (const QString &message=QString())
 Raises a custom error with an optional error message. More...
 
QString readElementText (ReadElementTextBehaviour behaviour)
 Convenience function to be called in case a StartElement was read. More...
 
QString readElementText ()
 
TokenType readNext ()
 Reads the next token and returns its type. More...
 
bool readNextStartElement ()
 Reads until the next start element within the current element. More...
 
void setDevice (QIODevice *device)
 Sets the current device to device. More...
 
void setEntityResolver (QXmlStreamEntityResolver *resolver)
 Makes resolver the new entityResolver(). More...
 
void setNamespaceProcessing (bool)
 
void skipCurrentElement ()
 Reads until the end of the current element, skipping any child nodes. More...
 
QStringRef text () const
 Returns the text of Characters , Comment , DTD , or EntityReference. More...
 
QString tokenString () const
 Returns the reader's current token as string. More...
 
TokenType tokenType () const
 Returns the type of the current token. More...
 
 ~QXmlStreamReader ()
 Destructs the reader. More...
 

Properties

QScopedPointer< QXmlStreamReaderPrivated_ptr
 

Detailed Description

The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming API.

Note
This class or function is reentrant.
Since
4.3

QXmlStreamReader is a faster and more convenient replacement for Qt's own SAX parser (see QXmlSimpleReader). In some cases it might also be a faster and more convenient alternative for use in applications that would otherwise use a DOM tree (see QDomDocument). QXmlStreamReader reads data either from a QIODevice (see setDevice()), or from a raw QByteArray (see addData()).

Qt provides QXmlStreamWriter for writing XML.

The basic concept of a stream reader is to report an XML document as a stream of tokens, similar to SAX. The main difference between QXmlStreamReader and SAX is how these XML tokens are reported. With SAX, the application must provide handlers (callback functions) that receive so-called XML events from the parser at the parser's convenience. With QXmlStreamReader, the application code itself drives the loop and pulls tokens from the reader, one after another, as it needs them. This is done by calling readNext(), where the reader reads from the input stream until it completes the next token, at which point it returns the tokenType(). A set of convenient functions including isStartElement() and text() can then be used to examine the token to obtain information about what has been read. The big advantage of this pulling approach is the possibility to build recursive descent parsers with it, meaning you can split your XML parsing code easily into different methods or classes. This makes it easy to keep track of the application's own state when parsing XML.

A typical loop with QXmlStreamReader looks like this:

...
while (!xml.atEnd()) {
xml.readNext();
... // do processing
}
if (xml.hasError()) {
... // do error handling
}

QXmlStreamReader is a well-formed XML 1.0 parser that does not include external parsed entities. As long as no error occurs, the application code can thus be assured that the data provided by the stream reader satisfies the W3C's criteria for well-formed XML. For example, you can be certain that all tags are indeed nested and closed properly, that references to internal entities have been replaced with the correct replacement text, and that attributes have been normalized or added according to the internal subset of the DTD.

If an error occurs while parsing, atEnd() and hasError() return true, and error() returns the error that occurred. The functions errorString(), lineNumber(), columnNumber(), and characterOffset() are for constructing an appropriate error or warning message. To simplify application code, QXmlStreamReader contains a raiseError() mechanism that lets you raise custom errors that trigger the same error handling described.

The QXmlStream Bookmarks Example illustrates how to use the recursive descent technique to read an XML bookmark file (XBEL) with a stream reader.

Namespaces

QXmlStream understands and resolves XML namespaces. E.g. in case of a StartElement, namespaceUri() returns the namespace the element is in, and name() returns the element's local name. The combination of namespaceUri and name uniquely identifies an element. If a namespace prefix was not declared in the XML entities parsed by the reader, the namespaceUri is empty.

If you parse XML data that does not utilize namespaces according to the XML specification or doesn't use namespaces at all, you can use the element's qualifiedName() instead. A qualified name is the element's prefix() followed by colon followed by the element's local name() - exactly like the element appears in the raw XML data. Since the mapping namespaceUri to prefix is neither unique nor universal, qualifiedName() should be avoided for namespace-compliant XML data.

In order to parse standalone documents that do use undeclared namespace prefixes, you can turn off namespace processing completely with the namespaceProcessing property.

Incremental parsing

QXmlStreamReader is an incremental parser. It can handle the case where the document can't be parsed all at once because it arrives in chunks (e.g. from multiple files, or over a network connection). When the reader runs out of data before the complete document has been parsed, it reports a PrematureEndOfDocumentError. When more data arrives, either because of a call to addData() or because more data is available through the network device(), the reader recovers from the PrematureEndOfDocumentError error and continues parsing the new data with the next call to readNext().

For example, if your application reads data from the network using a network access manager, you would issue a network request to the manager and receive a network reply in return. Since a QNetworkReply is a QIODevice, you connect its readyRead() signal to a custom slot, e.g. slotReadyRead() in the code snippet shown in the discussion for QNetworkAccessManager. In this slot, you read all available data with readAll() and pass it to the XML stream reader using addData(). Then you call your custom parsing function that reads the XML events from the reader.

Performance and memory consumption

QXmlStreamReader is memory-conservative by design, since it doesn't store the entire XML document tree in memory, but only the current token at the time it is reported. In addition, QXmlStreamReader avoids the many small string allocations that it normally takes to map an XML document to a convenient and Qt-ish API. It does this by reporting all string data as QStringRef rather than real QString objects. QStringRef is a thin wrapper around QString substrings that provides a subset of the QString API without the memory allocation and reference-counting overhead. Calling toString() on any of those objects returns an equivalent real QString object.

Definition at line 290 of file qxmlstream.h.

Enumerations

◆ Error

This enum specifies different error cases.

  • NoError No error has occurred.
  • CustomError A custom error has been raised with raiseError()
  • NotWellFormedError The parser internally raised an error due to the read XML not being well-formed.
  • PrematureEndOfDocumentError The input stream ended before a well-formed XML document was parsed. Recovery from this error is possible if more XML arrives in the stream, either by calling addData() or by waiting for it to arrive on the device().
  • UnexpectedElementError The parser encountered an element that was different to those it expected.
Enumerator
NoError 
UnexpectedElementError 
CustomError 
NotWellFormedError 
PrematureEndOfDocumentError 

Definition at line 385 of file qxmlstream.h.

◆ ReadElementTextBehaviour

This enum specifies the different behaviours of readElementText().

  • ErrorOnUnexpectedElement Raise an UnexpectedElementError and return what was read so far when a child element is encountered.
  • IncludeChildElements Recursively include the text from child elements.
  • SkipChildElements Skip child elements.
Since
4.6
Enumerator
ErrorOnUnexpectedElement 
IncludeChildElements 
SkipChildElements 

Definition at line 357 of file qxmlstream.h.

◆ TokenType

This enum specifies the type of token the reader just read.

  • NoToken The reader has not yet read anything.
  • EndDocument The reader reports the end of the document.
  • StartElement The reader reports the start of an element with namespaceUri() and name(). Empty elements are also reported as StartElement, followed directly by EndElement. The convenience function readElementText() can be called to concatenate all content until the corresponding EndElement. Attributes are reported in attributes(), namespace declarations in namespaceDeclarations().
  • Characters The reader reports characters in text(). If the characters are all white-space, isWhitespace() returns true. If the characters stem from a CDATA section, isCDATA() returns true.
  • Comment The reader reports a comment in text().
  • EntityReference The reader reports an entity reference that could not be resolved. The name of the reference is reported in name(), the replacement text in text().
Enumerator
NoToken 
Invalid 
StartDocument 
EndDocument 
StartElement 
EndElement 
Characters 
Comment 
DTD 
EntityReference 
ProcessingInstruction 

Definition at line 293 of file qxmlstream.h.

Constructors and Destructors

◆ QXmlStreamReader() [1/5]

QXmlStreamReader::QXmlStreamReader ( )

Constructs a stream reader.

See also
setDevice(), addData()

Definition at line 406 of file qxmlstream.cpp.

407  : d_ptr(new QXmlStreamReaderPrivate(this))
408 {
409 }
QScopedPointer< QXmlStreamReaderPrivate > d_ptr
Definition: qxmlstream.h:407

◆ QXmlStreamReader() [2/5]

QXmlStreamReader::QXmlStreamReader ( QIODevice device)

Creates a new stream reader that reads from device.

See also
setDevice(), clear()

Definition at line 415 of file qxmlstream.cpp.

416  : d_ptr(new QXmlStreamReaderPrivate(this))
417 {
418  setDevice(device);
419 }
QScopedPointer< QXmlStreamReaderPrivate > d_ptr
Definition: qxmlstream.h:407
void setDevice(QIODevice *device)
Sets the current device to device.
Definition: qxmlstream.cpp:489

◆ QXmlStreamReader() [3/5]

QXmlStreamReader::QXmlStreamReader ( const QByteArray data)

Creates a new stream reader that reads from data.

See also
addData(), clear(), setDevice()

Definition at line 426 of file qxmlstream.cpp.

427  : d_ptr(new QXmlStreamReaderPrivate(this))
428 {
430  d->dataBuffer = data;
431 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QScopedPointer< QXmlStreamReaderPrivate > d_ptr
Definition: qxmlstream.h:407
static const char * data(const QByteArray &arr)
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ QXmlStreamReader() [4/5]

QXmlStreamReader::QXmlStreamReader ( const QString data)

Creates a new stream reader that reads from data.

See also
addData(), clear(), setDevice()

Definition at line 438 of file qxmlstream.cpp.

439  : d_ptr(new QXmlStreamReaderPrivate(this))
440 {
442 #ifdef QT_NO_TEXTCODEC
443  d->dataBuffer = data.toLatin1();
444 #else
445  d->dataBuffer = d->codec->fromUnicode(data);
446  d->decoder = d->codec->makeDecoder();
447 #endif
448  d->lockEncoding = true;
449 
450 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QScopedPointer< QXmlStreamReaderPrivate > d_ptr
Definition: qxmlstream.h:407
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ QXmlStreamReader() [5/5]

QXmlStreamReader::QXmlStreamReader ( const char *  data)

Creates a new stream reader that reads from data.

See also
addData(), clear(), setDevice()

Definition at line 457 of file qxmlstream.cpp.

458  : d_ptr(new QXmlStreamReaderPrivate(this))
459 {
461  d->dataBuffer = QByteArray(data);
462 }
double d
Definition: qnumeric_p.h:62
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define Q_D(Class)
Definition: qglobal.h:2482
QScopedPointer< QXmlStreamReaderPrivate > d_ptr
Definition: qxmlstream.h:407
static const char * data(const QByteArray &arr)
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ ~QXmlStreamReader()

QXmlStreamReader::~QXmlStreamReader ( )

Destructs the reader.

Definition at line 467 of file qxmlstream.cpp.

468 {
470  if (d->deleteDevice)
471  delete d->device;
472 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

Functions

◆ addData() [1/3]

void QXmlStreamReader::addData ( const QByteArray data)

Adds more data for the reader to read.

This function does nothing if the reader has a device().

See also
readNext(), clear()

Definition at line 520 of file qxmlstream.cpp.

Referenced by addData().

521 {
523  if (d->device) {
524  qWarning("QXmlStreamReader: addData() with device()");
525  return;
526  }
527  d->dataBuffer += data;
528 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ addData() [2/3]

void QXmlStreamReader::addData ( const QString data)

Adds more data for the reader to read.

This function does nothing if the reader has a device().

See also
readNext(), clear()

Definition at line 536 of file qxmlstream.cpp.

537 {
539  d->lockEncoding = true;
540 #ifdef QT_NO_TEXTCODEC
541  addData(data.toLatin1());
542 #else
543  addData(d->codec->fromUnicode(data));
544 #endif
545 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
void addData(const QByteArray &data)
Adds more data for the reader to read.
Definition: qxmlstream.cpp:520
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ addData() [3/3]

void QXmlStreamReader::addData ( const char *  data)

Adds more data for the reader to read.

This function does nothing if the reader has a device().

See also
readNext(), clear()

Definition at line 553 of file qxmlstream.cpp.

554 {
556 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static const char * data(const QByteArray &arr)
void addData(const QByteArray &data)
Adds more data for the reader to read.
Definition: qxmlstream.cpp:520

◆ addExtraNamespaceDeclaration()

void QXmlStreamReader::addExtraNamespaceDeclaration ( const QXmlStreamNamespaceDeclaration extraNamespaceDeclaration)

Adds an extraNamespaceDeclaration.

Since
4.4

The declaration will be valid for children of the current element, or - should the function be called before any elements are read - for the entire XML document.

See also
namespaceDeclarations(), addExtraNamespaceDeclarations(), setNamespaceProcessing()

Definition at line 2110 of file qxmlstream.cpp.

2111 {
2113  QXmlStreamReaderPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push();
2114  namespaceDeclaration.prefix = d->addToStringStorage(extraNamespaceDeclaration.prefix());
2115  namespaceDeclaration.namespaceUri = d->addToStringStorage(extraNamespaceDeclaration.namespaceUri());
2116 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QStringRef namespaceUri() const
Returns the namespaceUri.
Definition: qxmlstream.h:216
QStringRef prefix() const
Returns the prefix.
Definition: qxmlstream.h:215
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ addExtraNamespaceDeclarations()

void QXmlStreamReader::addExtraNamespaceDeclarations ( const QXmlStreamNamespaceDeclarations extraNamespaceDeclarations)

Adds a vector of declarations specified by extraNamespaceDeclarations.

Since
4.4
See also
namespaceDeclarations(), addExtraNamespaceDeclaration()

Definition at line 2128 of file qxmlstream.cpp.

2129 {
2130  for (int i = 0; i < extraNamespaceDeclarations.size(); ++i)
2131  addExtraNamespaceDeclaration(extraNamespaceDeclarations.at(i));
2132 }
void addExtraNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &extraNamespaceDeclaraction)
Adds an extraNamespaceDeclaration.
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ atEnd()

bool QXmlStreamReader::atEnd ( ) const

Returns true if the reader has read until the end of the XML document, or if an error() has occurred and reading has been aborted.

Otherwise, it returns false.

When atEnd() and hasError() return true and error() returns PrematureEndOfDocumentError, it means the XML has been well-formed so far, but a complete XML document has not been parsed. The next chunk of XML can be added with addData(), if the XML is being read from a QByteArray, or by waiting for more data to arrive if the XML is being read from a QIODevice. Either way, atEnd() will return false once more data is available.

See also
hasError(), error(), device(), QIODevice::atEnd()

Definition at line 590 of file qxmlstream.cpp.

Referenced by QPatternist::ColoringMessageHandler::colorifyDescription(), QPatternist::XSLTTokenizer::insideAttributeSet(), QPatternist::XSLTTokenizer::insideChoose(), QPatternist::XSLTTokenizer::insideSequenceConstructor(), QPatternist::XSLTTokenizer::insideStylesheetModule(), Document::load(), QPatternist::XSLTTokenizer::outsideDocumentElement(), QScriptXmlParser::parse(), QPatternist::XsdSchemaParser::parse(), QSvgHandler::parse(), QPatternist::XsdSchemaParser::parseAll(), QPatternist::XsdSchemaParser::parseAlternative(), QPatternist::XsdSchemaParser::parseAnnotation(), QPatternist::XsdSchemaParser::parseAny(), QPatternist::XsdSchemaParser::parseAnyAttribute(), QPatternist::XsdSchemaParser::parseAppInfo(), QPatternist::XsdSchemaParser::parseAssertion(), QPatternist::XsdSchemaParser::parseChoice(), QPatternist::XsdSchemaParser::parseComplexContent(), QPatternist::XsdSchemaParser::parseComplexContentExtension(), QPatternist::XsdSchemaParser::parseComplexContentRestriction(), QPatternist::XsdSchemaParser::parseDefaultOpenContent(), QPatternist::XsdSchemaParser::parseDocumentation(), QPatternist::XsdSchemaParser::parseEnumerationFacet(), QPatternist::XsdSchemaParser::parseField(), QPatternist::XsdSchemaParser::parseFractionDigitsFacet(), QPatternist::XsdSchemaParser::parseGlobalAttribute(), QPatternist::XsdSchemaParser::parseGlobalComplexType(), QPatternist::XsdSchemaParser::parseGlobalElement(), QPatternist::XsdSchemaParser::parseGlobalSimpleType(), QPatternist::XsdSchemaParser::parseImport(), QPatternist::XsdSchemaParser::parseInclude(), QPatternist::XsdSchemaParser::parseKey(), QPatternist::XsdSchemaParser::parseKeyRef(), QPatternist::XsdSchemaParser::parseLengthFacet(), QPatternist::XsdSchemaParser::parseList(), QPatternist::XsdSchemaParser::parseLocalAll(), QPatternist::XsdSchemaParser::parseLocalAttribute(), QPatternist::XsdSchemaParser::parseLocalChoice(), QPatternist::XsdSchemaParser::parseLocalComplexType(), QPatternist::XsdSchemaParser::parseLocalElement(), QPatternist::XsdSchemaParser::parseLocalSequence(), QPatternist::XsdSchemaParser::parseLocalSimpleType(), QPatternist::XsdSchemaParser::parseMaxExclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxInclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxLengthFacet(), QPatternist::XsdSchemaParser::parseMinExclusiveFacet(), QPatternist::XsdSchemaParser::parseMinInclusiveFacet(), QPatternist::XsdSchemaParser::parseMinLengthFacet(), QPatternist::XsdSchemaParser::parseNamedAttributeGroup(), QPatternist::XsdSchemaParser::parseNamedGroup(), QPatternist::XsdSchemaParser::parseNotation(), QPatternist::XsdSchemaParser::parseOpenContent(), QPatternist::XsdSchemaParser::parsePatternFacet(), QPatternist::XsdSchemaParser::parseRedefine(), QPatternist::XsdSchemaParser::parseReferredAttributeGroup(), QPatternist::XsdSchemaParser::parseReferredGroup(), QPatternist::XsdSchemaParser::parseSchema(), QPatternist::XsdSchemaParser::parseSelector(), QPatternist::XsdSchemaParser::parseSequence(), QPatternist::XsdSchemaParser::parseSimpleContent(), QPatternist::XsdSchemaParser::parseSimpleContentExtension(), QPatternist::XsdSchemaParser::parseSimpleContentRestriction(), QPatternist::XsdSchemaParser::parseSimpleRestriction(), QPatternist::XsdSchemaParser::parseTotalDigitsFacet(), QPatternist::XsdSchemaParser::parseUnion(), QPatternist::XsdSchemaParser::parseUnique(), QPatternist::XsdSchemaParser::parseUnknown(), QPatternist::XsdSchemaParser::parseUnknownDocumentation(), QPatternist::XsdSchemaParser::parseWhiteSpaceFacet(), QPatternist::XSLTTokenizer::queueParams(), QPatternist::XSLTTokenizer::queueSorting(), QPatternist::XSLTTokenizer::queueWithParams(), QPatternist::XSLTTokenizer::readElementText(), QPatternist::XSLTTokenizer::skipSubTree(), QPatternist::AccelTreeResourceLoader::streamToReceiver(), and tokenUntil().

591 {
592  Q_D(const QXmlStreamReader);
593  if (d->atEnd
594  && ((d->type == QXmlStreamReader::Invalid && d->error == PrematureEndOfDocumentError)
595  || (d->type == QXmlStreamReader::EndDocument))) {
596  if (d->device)
597  return d->device->atEnd();
598  else
599  return !d->dataBuffer.size();
600  }
601  return (d->atEnd || d->type == QXmlStreamReader::Invalid);
602 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ attributes()

QXmlStreamAttributes QXmlStreamReader::attributes ( ) const

Returns the attributes of a StartElement.

Definition at line 2317 of file qxmlstream.cpp.

Referenced by QPatternist::ColoringMessageHandler::colorifyDescription(), QPatternist::XSLTTokenizer::handleXSLTVersion(), Document::load(), QScriptXmlParser::parse(), QSvgHandler::parse(), QPatternist::AccelTreeResourceLoader::streamToReceiver(), tokenUntil(), and QXmlStreamWriter::writeCurrentToken().

2318 {
2319  Q_D(const QXmlStreamReader);
2320  return d->attributes;
2321 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ characterOffset()

qint64 QXmlStreamReader::characterOffset ( ) const

Returns the current character offset, starting with 0.

See also
lineNumber(), columnNumber()

Definition at line 1979 of file qxmlstream.cpp.

1980 {
1981  Q_D(const QXmlStreamReader);
1982  return d->characterOffset + d->readBufferPos;
1983 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ clear()

void QXmlStreamReader::clear ( )

Removes any device() or data from the reader and resets its internal state to the initial state.

See also
addData()

Definition at line 564 of file qxmlstream.cpp.

565 {
567  d->init();
568  if (d->device) {
569  if (d->deleteDevice)
570  delete d->device;
571  d->device = 0;
572  }
573 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ columnNumber()

qint64 QXmlStreamReader::columnNumber ( ) const

Returns the current column number, starting with 0.

See also
lineNumber(), characterOffset()

Definition at line 1969 of file qxmlstream.cpp.

Referenced by QPatternist::XsdSchemaParser::currentSourceLocation(), QPatternist::XSLTTokenizer::currentSourceLocator(), and QPatternist::AccelTreeResourceLoader::streamToReceiver().

1970 {
1971  Q_D(const QXmlStreamReader);
1972  return d->characterOffset - d->lastLineStart + d->readBufferPos;
1973 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ device()

QIODevice * QXmlStreamReader::device ( ) const

Returns the current device associated with the QXmlStreamReader, or 0 if no device has been assigned.

See also
setDevice()

Definition at line 507 of file qxmlstream.cpp.

Referenced by setDevice().

508 {
509  Q_D(const QXmlStreamReader);
510  return d->device;
511 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ documentEncoding()

QStringRef QXmlStreamReader::documentEncoding ( ) const

If the state() is StartDocument , this function returns the encoding string as specified in the XML declaration.

Since
4.4

Otherwise an empty string is returned.

Definition at line 3031 of file qxmlstream.cpp.

Referenced by QDeclarativeXMLHttpRequest::findTextCodec(), and Document::load().

3032 {
3033  Q_D(const QXmlStreamReader);
3034  if (d->type == QXmlStreamReader::StartDocument)
3035  return d->documentEncoding;
3036  return QStringRef();
3037 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ documentVersion()

QStringRef QXmlStreamReader::documentVersion ( ) const

If the state() is StartDocument , this function returns the version string as specified in the XML declaration.

Since
4.4

Otherwise an empty string is returned.

Definition at line 3013 of file qxmlstream.cpp.

Referenced by Document::load().

3014 {
3015  Q_D(const QXmlStreamReader);
3016  if (d->type == QXmlStreamReader::StartDocument)
3017  return d->documentVersion;
3018  return QStringRef();
3019 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ dtdName()

QStringRef QXmlStreamReader::dtdName ( ) const

If the state() is DTD , this function returns the DTD's name.

Since
4.4

Otherwise an empty string is returned.

Definition at line 2035 of file qxmlstream.cpp.

2036 {
2037  Q_D(const QXmlStreamReader);
2038  if (d->type == QXmlStreamReader::DTD)
2039  return d->dtdName;
2040  return QStringRef();
2041 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ dtdPublicId()

QStringRef QXmlStreamReader::dtdPublicId ( ) const

If the state() is DTD , this function returns the DTD's public identifier.

Since
4.4

Otherwise an empty string is returned.

Definition at line 2053 of file qxmlstream.cpp.

2054 {
2055  Q_D(const QXmlStreamReader);
2056  if (d->type == QXmlStreamReader::DTD)
2057  return d->dtdPublicId;
2058  return QStringRef();
2059 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ dtdSystemId()

QStringRef QXmlStreamReader::dtdSystemId ( ) const

If the state() is DTD , this function returns the DTD's system identifier.

Since
4.4

Otherwise an empty string is returned.

Definition at line 2071 of file qxmlstream.cpp.

2072 {
2073  Q_D(const QXmlStreamReader);
2074  if (d->type == QXmlStreamReader::DTD)
2075  return d->dtdSystemId;
2076  return QStringRef();
2077 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ entityDeclarations()

QXmlStreamEntityDeclarations QXmlStreamReader::entityDeclarations ( ) const

If the state() is DTD , this function returns the DTD's unparsed (external) entity declarations.

Otherwise an empty vector is returned.

The QXmlStreamEntityDeclarations class is defined to be a QVector of QXmlStreamEntityDeclaration.

Definition at line 2017 of file qxmlstream.cpp.

2018 {
2019  Q_D(const QXmlStreamReader);
2020  if (d->entityDeclarations.size())
2021  const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd();
2022  return d->publicEntityDeclarations;
2023 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ entityResolver()

QXmlStreamEntityResolver * QXmlStreamReader::entityResolver ( ) const

Returns the entity resolver, or 0 if there is no entity resolver.

Since
4.4
See also
setEntityResolver()

Definition at line 264 of file qxmlstream.cpp.

265 {
266  Q_D(const QXmlStreamReader);
267  return d->entityResolver;
268 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ error()

QXmlStreamReader::Error QXmlStreamReader::error ( ) const

Returns the type of the current error, or NoError if no error occurred.

See also
errorString(), raiseError()

Definition at line 2228 of file qxmlstream.cpp.

Referenced by QPatternist::XsdSchemaParser::addAttribute(), QPatternist::XsdSchemaParser::addAttributeGroup(), QPatternist::XsdSchemaParser::addElement(), QPatternist::XsdSchemaParser::addElementGroup(), QPatternist::XsdSchemaParser::addFacet(), QPatternist::XsdSchemaParser::addIdentityConstraint(), QPatternist::XsdSchemaParser::addNotation(), QPatternist::XsdSchemaParser::addType(), QPatternist::XsdSchemaParser::attributeContentError(), QPatternist::XSLTTokenizer::checkForParseError(), QPatternist::XsdSchemaParser::convertName(), QPatternist::XsdSchemaParser::error(), QPatternist::XSLTTokenizer::handleStandardAttributes(), QPatternist::XSLTTokenizer::handleValidationAttributes(), QPatternist::XSLTTokenizer::handleXSLTVersion(), QPatternist::XSLTTokenizer::insideChoose(), QPatternist::XSLTTokenizer::insideSequenceConstructor(), QPatternist::XSLTTokenizer::insideStylesheetModule(), QPatternist::XSLTTokenizer::insideTemplate(), QPatternist::XSLTTokenizer::outsideDocumentElement(), QPatternist::XsdSchemaParser::parse(), QPatternist::XsdSchemaParser::parseAll(), QPatternist::XsdSchemaParser::parseAlternative(), QPatternist::XsdSchemaParser::parseAny(), QPatternist::XsdSchemaParser::parseAnyAttribute(), QPatternist::XsdSchemaParser::parseGlobalAttribute(), QPatternist::XsdSchemaParser::parseGlobalComplexType(), QPatternist::XsdSchemaParser::parseGlobalElement(), QPatternist::XsdSchemaParser::parseImport(), QPatternist::XsdSchemaParser::parseList(), QPatternist::XsdSchemaParser::parseLocalAll(), QPatternist::XsdSchemaParser::parseLocalAttribute(), QPatternist::XsdSchemaParser::parseLocalElement(), QPatternist::XsdSchemaParser::parseMinMaxConstraint(), QPatternist::XsdSchemaParser::parseNotation(), QPatternist::XsdSchemaParser::parseRedefine(), QPatternist::XsdSchemaParser::parseSchema(), QPatternist::XsdSchemaParser::parseSimpleRestriction(), QPatternist::XsdSchemaParser::parseUnion(), QPatternist::XsdSchemaParser::parseUnknown(), QPatternist::XSLTTokenizer::queueParams(), QPatternist::XSLTTokenizer::queueSelectOrSequenceConstructor(), QPatternist::XSLTTokenizer::queueSorting(), QPatternist::XSLTTokenizer::queueVariableDeclaration(), QPatternist::XSLTTokenizer::readAlternativeAttribute(), QPatternist::XsdSchemaParser::readBlockingConstraintAttribute(), QPatternist::XsdSchemaParser::readDerivationConstraintAttribute(), QPatternist::XSLTTokenizer::readToggleAttribute(), QPatternist::XSLTTokenizer::skipBodyOfParam(), QPatternist::XSLTTokenizer::unexpectedContent(), and QPatternist::XsdSchemaParser::validateIdAttribute().

2229 {
2230  Q_D(const QXmlStreamReader);
2231  if (d->type == QXmlStreamReader::Invalid)
2232  return d->error;
2233  return NoError;
2234 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ errorString()

QString QXmlStreamReader::errorString ( ) const

Returns the error message that was set with raiseError().

See also
error(), lineNumber(), columnNumber(), characterOffset()

Definition at line 2216 of file qxmlstream.cpp.

Referenced by QPatternist::XSLTTokenizer::checkForParseError(), QPatternist::XsdSchemaParser::parse(), QPatternist::AccelTreeResourceLoader::streamToReceiver(), and QPatternist::XSLTTokenizer::unexpectedContent().

2217 {
2218  Q_D(const QXmlStreamReader);
2219  if (d->type == QXmlStreamReader::Invalid)
2220  return d->errorString;
2221  return QString();
2222 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ hasError()

bool QXmlStreamReader::hasError ( ) const
inline

Returns true if an error has occurred, otherwise false.

See also
errorString(), error()

Definition at line 396 of file qxmlstream.h.

Referenced by QPatternist::XSLTTokenizer::checkForParseError(), QPatternist::ColoringMessageHandler::colorifyDescription(), QPatternist::XSLTTokenizer::insideSequenceConstructor(), and Document::load().

397  {
398  return error() != NoError;
399  }
Error error() const
Returns the type of the current error, or NoError if no error occurred.

◆ isCDATA()

bool QXmlStreamReader::isCDATA ( ) const

Returns true if the reader reports characters that stem from a CDATA section; otherwise returns false.

See also
isCharacters(), text()

Definition at line 2982 of file qxmlstream.cpp.

Referenced by Document::load(), and QXmlStreamWriter::writeCurrentToken().

2983 {
2984  Q_D(const QXmlStreamReader);
2985  return d->type == QXmlStreamReader::Characters && d->isCDATA;
2986 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ isCharacters()

bool QXmlStreamReader::isCharacters ( ) const
inline

Returns true if tokenType() equals Characters ; otherwise returns false.

See also
isWhitespace(), isCDATA()

Definition at line 339 of file qxmlstream.h.

Referenced by QPatternist::XsdSchemaParser::parseNotation().

339 { return tokenType() == Characters; }
TokenType tokenType() const
Returns the type of the current token.
Definition: qxmlstream.cpp:656

◆ isComment()

bool QXmlStreamReader::isComment ( ) const
inline

Returns true if tokenType() equals Comment ; otherwise returns false.

Definition at line 342 of file qxmlstream.h.

342 { return tokenType() == Comment; }
TokenType tokenType() const
Returns the type of the current token.
Definition: qxmlstream.cpp:656

◆ isDTD()

bool QXmlStreamReader::isDTD ( ) const
inline

Returns true if tokenType() equals DTD ; otherwise returns false.

Definition at line 343 of file qxmlstream.h.

343 { return tokenType() == DTD; }
TokenType tokenType() const
Returns the type of the current token.
Definition: qxmlstream.cpp:656

◆ isEndDocument()

bool QXmlStreamReader::isEndDocument ( ) const
inline

Returns true if tokenType() equals EndDocument ; otherwise returns false.

Definition at line 336 of file qxmlstream.h.

336 { return tokenType() == EndDocument; }
TokenType tokenType() const
Returns the type of the current token.
Definition: qxmlstream.cpp:656

◆ isEndElement()

bool QXmlStreamReader::isEndElement ( ) const
inline

Returns true if tokenType() equals EndElement ; otherwise returns false.

Definition at line 338 of file qxmlstream.h.

Referenced by QPatternist::XSLTTokenizer::insideStylesheetModule(), QPatternist::XsdSchemaParser::parseAll(), QPatternist::XsdSchemaParser::parseAlternative(), QPatternist::XsdSchemaParser::parseAnnotation(), QPatternist::XsdSchemaParser::parseAny(), QPatternist::XsdSchemaParser::parseAnyAttribute(), QPatternist::XsdSchemaParser::parseAppInfo(), QPatternist::XsdSchemaParser::parseAssertion(), QPatternist::XsdSchemaParser::parseChoice(), QPatternist::XsdSchemaParser::parseComplexContent(), QPatternist::XsdSchemaParser::parseComplexContentExtension(), QPatternist::XsdSchemaParser::parseComplexContentRestriction(), QPatternist::XsdSchemaParser::parseDefaultOpenContent(), QPatternist::XsdSchemaParser::parseDocumentation(), QPatternist::XsdSchemaParser::parseEnumerationFacet(), QPatternist::XsdSchemaParser::parseField(), QPatternist::XsdSchemaParser::parseFractionDigitsFacet(), QPatternist::XsdSchemaParser::parseGlobalAttribute(), QPatternist::XsdSchemaParser::parseGlobalComplexType(), QPatternist::XsdSchemaParser::parseGlobalElement(), QPatternist::XsdSchemaParser::parseGlobalSimpleType(), QPatternist::XsdSchemaParser::parseImport(), QPatternist::XsdSchemaParser::parseInclude(), QPatternist::XsdSchemaParser::parseKey(), QPatternist::XsdSchemaParser::parseKeyRef(), QPatternist::XsdSchemaParser::parseLengthFacet(), QPatternist::XsdSchemaParser::parseList(), QPatternist::XsdSchemaParser::parseLocalAll(), QPatternist::XsdSchemaParser::parseLocalAttribute(), QPatternist::XsdSchemaParser::parseLocalChoice(), QPatternist::XsdSchemaParser::parseLocalComplexType(), QPatternist::XsdSchemaParser::parseLocalElement(), QPatternist::XsdSchemaParser::parseLocalSequence(), QPatternist::XsdSchemaParser::parseLocalSimpleType(), QPatternist::XsdSchemaParser::parseMaxExclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxInclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxLengthFacet(), QPatternist::XsdSchemaParser::parseMinExclusiveFacet(), QPatternist::XsdSchemaParser::parseMinInclusiveFacet(), QPatternist::XsdSchemaParser::parseMinLengthFacet(), QPatternist::XsdSchemaParser::parseNamedAttributeGroup(), QPatternist::XsdSchemaParser::parseNamedGroup(), QPatternist::XsdSchemaParser::parseNotation(), QPatternist::XsdSchemaParser::parseOpenContent(), QPatternist::XsdSchemaParser::parsePatternFacet(), QPatternist::XsdSchemaParser::parseRedefine(), QPatternist::XsdSchemaParser::parseReferredAttributeGroup(), QPatternist::XsdSchemaParser::parseReferredGroup(), QPatternist::XsdSchemaParser::parseSchema(), QPatternist::XsdSchemaParser::parseSelector(), QPatternist::XsdSchemaParser::parseSequence(), QPatternist::XsdSchemaParser::parseSimpleContent(), QPatternist::XsdSchemaParser::parseSimpleContentExtension(), QPatternist::XsdSchemaParser::parseSimpleContentRestriction(), QPatternist::XsdSchemaParser::parseSimpleRestriction(), QPatternist::XsdSchemaParser::parseTotalDigitsFacet(), QPatternist::XsdSchemaParser::parseUnion(), QPatternist::XsdSchemaParser::parseUnique(), QPatternist::XsdSchemaParser::parseUnknown(), QPatternist::XsdSchemaParser::parseUnknownDocumentation(), QPatternist::XsdSchemaParser::parseWhiteSpaceFacet(), readNextStartElement(), and skipCurrentElement().

338 { return tokenType() == EndElement; }
TokenType tokenType() const
Returns the type of the current token.
Definition: qxmlstream.cpp:656

◆ isEntityReference()

bool QXmlStreamReader::isEntityReference ( ) const
inline

Returns true if tokenType() equals EntityReference ; otherwise returns false.

Definition at line 344 of file qxmlstream.h.

Referenced by QPatternist::XsdSchemaParser::parseNotation().

344 { return tokenType() == EntityReference; }
TokenType tokenType() const
Returns the type of the current token.
Definition: qxmlstream.cpp:656

◆ isProcessingInstruction()

bool QXmlStreamReader::isProcessingInstruction ( ) const
inline

Returns true if tokenType() equals ProcessingInstruction ; otherwise returns false.

Definition at line 345 of file qxmlstream.h.

345 { return tokenType() == ProcessingInstruction; }
TokenType tokenType() const
Returns the type of the current token.
Definition: qxmlstream.cpp:656

◆ isStandaloneDocument()

bool QXmlStreamReader::isStandaloneDocument ( ) const

Returns true if this document has been declared standalone in the XML declaration; otherwise returns false.

If no XML declaration has been parsed, this function returns false.

Definition at line 2996 of file qxmlstream.cpp.

Referenced by Document::load().

2997 {
2998  Q_D(const QXmlStreamReader);
2999  return d->standalone;
3000 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ isStartDocument()

bool QXmlStreamReader::isStartDocument ( ) const
inline

Returns true if tokenType() equals StartDocument ; otherwise returns false.

Definition at line 335 of file qxmlstream.h.

335 { return tokenType() == StartDocument; }
TokenType tokenType() const
Returns the type of the current token.
Definition: qxmlstream.cpp:656

◆ isStartElement()

bool QXmlStreamReader::isStartElement ( ) const
inline

Returns true if tokenType() equals StartElement ; otherwise returns false.

Definition at line 337 of file qxmlstream.h.

Referenced by QPatternist::ElementNamespaceHandler::ElementNamespaceHandler(), QPatternist::XsdSchemaParser::parse(), QPatternist::XsdSchemaParser::parseAll(), QPatternist::XsdSchemaParser::parseAlternative(), QPatternist::XsdSchemaParser::parseAnnotation(), QPatternist::XsdSchemaParser::parseAny(), QPatternist::XsdSchemaParser::parseAnyAttribute(), QPatternist::XsdSchemaParser::parseAppInfo(), QPatternist::XsdSchemaParser::parseAssertion(), QPatternist::XsdSchemaParser::parseChoice(), QPatternist::XsdSchemaParser::parseComplexContent(), QPatternist::XsdSchemaParser::parseComplexContentExtension(), QPatternist::XsdSchemaParser::parseComplexContentRestriction(), QPatternist::XsdSchemaParser::parseDefaultOpenContent(), QPatternist::XsdSchemaParser::parseDocumentation(), QPatternist::XsdSchemaParser::parseEnumerationFacet(), QPatternist::XsdSchemaParser::parseField(), QPatternist::XsdSchemaParser::parseFractionDigitsFacet(), QPatternist::XsdSchemaParser::parseGlobalAttribute(), QPatternist::XsdSchemaParser::parseGlobalComplexType(), QPatternist::XsdSchemaParser::parseGlobalElement(), QPatternist::XsdSchemaParser::parseGlobalSimpleType(), QPatternist::XsdSchemaParser::parseImport(), QPatternist::XsdSchemaParser::parseInclude(), QPatternist::XsdSchemaParser::parseKey(), QPatternist::XsdSchemaParser::parseKeyRef(), QPatternist::XsdSchemaParser::parseLengthFacet(), QPatternist::XsdSchemaParser::parseList(), QPatternist::XsdSchemaParser::parseLocalAll(), QPatternist::XsdSchemaParser::parseLocalAttribute(), QPatternist::XsdSchemaParser::parseLocalChoice(), QPatternist::XsdSchemaParser::parseLocalComplexType(), QPatternist::XsdSchemaParser::parseLocalElement(), QPatternist::XsdSchemaParser::parseLocalSequence(), QPatternist::XsdSchemaParser::parseLocalSimpleType(), QPatternist::XsdSchemaParser::parseMaxExclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxInclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxLengthFacet(), QPatternist::XsdSchemaParser::parseMinExclusiveFacet(), QPatternist::XsdSchemaParser::parseMinInclusiveFacet(), QPatternist::XsdSchemaParser::parseMinLengthFacet(), QPatternist::XsdSchemaParser::parseNamedAttributeGroup(), QPatternist::XsdSchemaParser::parseNamedGroup(), QPatternist::XsdSchemaParser::parseNotation(), QPatternist::XsdSchemaParser::parseOpenContent(), QPatternist::XsdSchemaParser::parsePatternFacet(), QPatternist::XsdSchemaParser::parseRedefine(), QPatternist::XsdSchemaParser::parseReferredAttributeGroup(), QPatternist::XsdSchemaParser::parseReferredGroup(), QPatternist::XsdSchemaParser::parseSchema(), QPatternist::XsdSchemaParser::parseSelector(), QPatternist::XsdSchemaParser::parseSequence(), QPatternist::XsdSchemaParser::parseSimpleContent(), QPatternist::XsdSchemaParser::parseSimpleContentExtension(), QPatternist::XsdSchemaParser::parseSimpleContentRestriction(), QPatternist::XsdSchemaParser::parseSimpleRestriction(), QPatternist::XsdSchemaParser::parseTotalDigitsFacet(), QPatternist::XsdSchemaParser::parseUnion(), QPatternist::XsdSchemaParser::parseUnique(), QPatternist::XsdSchemaParser::parseUnknown(), QPatternist::XsdSchemaParser::parseUnknownDocumentation(), QPatternist::XsdSchemaParser::parseWhiteSpaceFacet(), readNextStartElement(), and skipCurrentElement().

337 { return tokenType() == StartElement; }
TokenType tokenType() const
Returns the type of the current token.
Definition: qxmlstream.cpp:656

◆ isWhitespace()

bool QXmlStreamReader::isWhitespace ( ) const

Returns true if the reader reports characters that only consist of white-space; otherwise returns false.

See also
isCharacters(), text()

Definition at line 2971 of file qxmlstream.cpp.

Referenced by QPatternist::MaintainingReader< XSLTTokenLookup >::isWhitespace(), and QPatternist::AccelTreeResourceLoader::streamToReceiver().

2972 {
2973  Q_D(const QXmlStreamReader);
2974  return d->type == QXmlStreamReader::Characters && d->isWhitespace;
2975 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ lineNumber()

qint64 QXmlStreamReader::lineNumber ( ) const

Returns the current line number, starting with 1.

See also
columnNumber(), characterOffset()

Definition at line 1959 of file qxmlstream.cpp.

Referenced by QPatternist::XsdSchemaParser::currentSourceLocation(), QPatternist::XSLTTokenizer::currentSourceLocator(), and QPatternist::AccelTreeResourceLoader::streamToReceiver().

1960 {
1961  Q_D(const QXmlStreamReader);
1962  return d->lineNumber + 1; // in public we start with 1
1963 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ name()

QStringRef QXmlStreamReader::name ( ) const

Returns the local name of a StartElement, EndElement, or an EntityReference.

See also
namespaceUri(), qualifiedName()

Definition at line 2261 of file qxmlstream.cpp.

Referenced by QPatternist::ColoringMessageHandler::colorifyDescription(), QPatternist::ElementNamespaceHandler::ElementNamespaceHandler(), QPatternist::XSLTTokenizer::insideStylesheetModule(), QPatternist::XSLTTokenizer::isElement(), QPatternist::XSLTTokenizer::isStylesheetElement(), Document::load(), QScriptXmlParser::parse(), QPatternist::XsdSchemaParser::parse(), QSvgHandler::parse(), QPatternist::XsdSchemaParser::parseAll(), QPatternist::XsdSchemaParser::parseAlternative(), QPatternist::XsdSchemaParser::parseAnnotation(), QPatternist::XsdSchemaParser::parseAny(), QPatternist::XsdSchemaParser::parseAnyAttribute(), QPatternist::XsdSchemaParser::parseAssertion(), QPatternist::XsdSchemaParser::parseChoice(), QPatternist::XsdSchemaParser::parseComplexContent(), QPatternist::XsdSchemaParser::parseComplexContentExtension(), QPatternist::XsdSchemaParser::parseComplexContentRestriction(), QPatternist::XsdSchemaParser::parseDefaultOpenContent(), QPatternist::XsdSchemaParser::parseEnumerationFacet(), QPatternist::XsdSchemaParser::parseField(), QPatternist::XsdSchemaParser::parseFractionDigitsFacet(), QPatternist::XsdSchemaParser::parseGlobalAttribute(), QPatternist::XsdSchemaParser::parseGlobalComplexType(), QPatternist::XsdSchemaParser::parseGlobalElement(), QPatternist::XsdSchemaParser::parseGlobalSimpleType(), QPatternist::XsdSchemaParser::parseImport(), QPatternist::XsdSchemaParser::parseInclude(), QPatternist::XsdSchemaParser::parseKey(), QPatternist::XsdSchemaParser::parseKeyRef(), QPatternist::XsdSchemaParser::parseLengthFacet(), QPatternist::XsdSchemaParser::parseList(), QPatternist::XsdSchemaParser::parseLocalAll(), QPatternist::XsdSchemaParser::parseLocalAttribute(), QPatternist::XsdSchemaParser::parseLocalChoice(), QPatternist::XsdSchemaParser::parseLocalComplexType(), QPatternist::XsdSchemaParser::parseLocalElement(), QPatternist::XsdSchemaParser::parseLocalSequence(), QPatternist::XsdSchemaParser::parseLocalSimpleType(), QPatternist::XsdSchemaParser::parseMaxExclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxInclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxLengthFacet(), QPatternist::XsdSchemaParser::parseMinExclusiveFacet(), QPatternist::XsdSchemaParser::parseMinInclusiveFacet(), QPatternist::XsdSchemaParser::parseMinLengthFacet(), QPatternist::XsdSchemaParser::parseNamedAttributeGroup(), QPatternist::XsdSchemaParser::parseNamedGroup(), QPatternist::XsdSchemaParser::parseNotation(), QPatternist::XsdSchemaParser::parseOpenContent(), QPatternist::XsdSchemaParser::parsePatternFacet(), QPatternist::XsdSchemaParser::parseRedefine(), QPatternist::XsdSchemaParser::parseReferredAttributeGroup(), QPatternist::XsdSchemaParser::parseReferredGroup(), QPatternist::XsdSchemaParser::parseSchema(), QPatternist::XsdSchemaParser::parseSelector(), QPatternist::XsdSchemaParser::parseSequence(), QPatternist::XsdSchemaParser::parseSimpleContent(), QPatternist::XsdSchemaParser::parseSimpleContentExtension(), QPatternist::XsdSchemaParser::parseSimpleContentRestriction(), QPatternist::XsdSchemaParser::parseSimpleRestriction(), QPatternist::XsdSchemaParser::parseTotalDigitsFacet(), QPatternist::XsdSchemaParser::parseUnion(), QPatternist::XsdSchemaParser::parseUnique(), QPatternist::XsdSchemaParser::parseUnknown(), QPatternist::XsdSchemaParser::parseWhiteSpaceFacet(), QPatternist::XSLTTokenizer::readToggleAttribute(), QPatternist::XsdSchemaParser::setupBuiltinTypeNames(), QPatternist::XSLTTokenizer::skipBodyOfParam(), QPatternist::AccelTreeResourceLoader::streamToReceiver(), QPatternist::XSLTTokenizer::unexpectedContent(), QPatternist::TagValidationHandler::validate(), and QXmlStreamWriter::writeCurrentToken().

2262 {
2263  Q_D(const QXmlStreamReader);
2264  return d->name;
2265 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ namespaceDeclarations()

QXmlStreamNamespaceDeclarations QXmlStreamReader::namespaceDeclarations ( ) const

If the state() is StartElement , this function returns the element's namespace declarations.

Otherwise an empty vector is returned.

The QXmlStreamNamespaceDeclaration class is defined to be a QVector of QXmlStreamNamespaceDeclaration.

See also
addExtraNamespaceDeclaration(), addExtraNamespaceDeclarations()

Definition at line 2088 of file qxmlstream.cpp.

Referenced by QPatternist::ElementNamespaceHandler::ElementNamespaceHandler(), QPatternist::XsdSchemaParser::parseUnknown(), QPatternist::XsdSchemaParser::parseUnknownDocumentation(), QPatternist::XSLTTokenizer::queueNamespaceDeclarations(), QXmlStreamPrivateTagStack::QXmlStreamPrivateTagStack(), QPatternist::AccelTreeResourceLoader::streamToReceiver(), and QXmlStreamWriter::writeCurrentToken().

2089 {
2090  Q_D(const QXmlStreamReader);
2091  if (d->publicNamespaceDeclarations.isEmpty() && d->type == StartElement)
2092  const_cast<QXmlStreamReaderPrivate *>(d)->resolvePublicNamespaces();
2093  return d->publicNamespaceDeclarations;
2094 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ namespaceProcessing()

bool QXmlStreamReader::namespaceProcessing ( ) const

This property controls whether or not the stream reader processes namespaces.

the namespace-processing flag of the stream reader

If enabled, the reader processes namespaces, otherwise it does not.

By default, namespace-processing is enabled.

Definition at line 788 of file qxmlstream.cpp.

789 {
790  Q_D(const QXmlStreamReader);
791  return d->namespaceProcessing;
792 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ namespaceUri()

QStringRef QXmlStreamReader::namespaceUri ( ) const

Returns the namespaceUri of a StartElement or EndElement.

See also
name(), qualifiedName()

Definition at line 2272 of file qxmlstream.cpp.

Referenced by QPatternist::ElementNamespaceHandler::ElementNamespaceHandler(), QPatternist::XSLTTokenizer::insideStylesheetModule(), QPatternist::XSLTTokenizer::isXSLT(), Document::load(), QPatternist::XsdSchemaParser::parse(), QPatternist::XsdSchemaParser::parseAll(), QPatternist::XsdSchemaParser::parseAlternative(), QPatternist::XsdSchemaParser::parseAnnotation(), QPatternist::XsdSchemaParser::parseAny(), QPatternist::XsdSchemaParser::parseAnyAttribute(), QPatternist::XsdSchemaParser::parseAssertion(), QPatternist::XsdSchemaParser::parseChoice(), QPatternist::XsdSchemaParser::parseComplexContent(), QPatternist::XsdSchemaParser::parseComplexContentExtension(), QPatternist::XsdSchemaParser::parseComplexContentRestriction(), QPatternist::XsdSchemaParser::parseDefaultOpenContent(), QPatternist::XsdSchemaParser::parseEnumerationFacet(), QPatternist::XsdSchemaParser::parseField(), QPatternist::XsdSchemaParser::parseFractionDigitsFacet(), QPatternist::XsdSchemaParser::parseGlobalAttribute(), QPatternist::XsdSchemaParser::parseGlobalComplexType(), QPatternist::XsdSchemaParser::parseGlobalElement(), QPatternist::XsdSchemaParser::parseGlobalSimpleType(), QPatternist::XsdSchemaParser::parseImport(), QPatternist::XsdSchemaParser::parseInclude(), QPatternist::XsdSchemaParser::parseKey(), QPatternist::XsdSchemaParser::parseKeyRef(), QPatternist::XsdSchemaParser::parseLengthFacet(), QPatternist::XsdSchemaParser::parseList(), QPatternist::XsdSchemaParser::parseLocalAll(), QPatternist::XsdSchemaParser::parseLocalAttribute(), QPatternist::XsdSchemaParser::parseLocalChoice(), QPatternist::XsdSchemaParser::parseLocalComplexType(), QPatternist::XsdSchemaParser::parseLocalElement(), QPatternist::XsdSchemaParser::parseLocalSequence(), QPatternist::XsdSchemaParser::parseLocalSimpleType(), QPatternist::XsdSchemaParser::parseMaxExclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxInclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxLengthFacet(), QPatternist::XsdSchemaParser::parseMinExclusiveFacet(), QPatternist::XsdSchemaParser::parseMinInclusiveFacet(), QPatternist::XsdSchemaParser::parseMinLengthFacet(), QPatternist::XsdSchemaParser::parseNamedAttributeGroup(), QPatternist::XsdSchemaParser::parseNamedGroup(), QPatternist::XsdSchemaParser::parseNotation(), QPatternist::XsdSchemaParser::parseOpenContent(), QPatternist::XsdSchemaParser::parsePatternFacet(), QPatternist::XsdSchemaParser::parseRedefine(), QPatternist::XsdSchemaParser::parseReferredAttributeGroup(), QPatternist::XsdSchemaParser::parseReferredGroup(), QPatternist::XsdSchemaParser::parseSchema(), QPatternist::XsdSchemaParser::parseSelector(), QPatternist::XsdSchemaParser::parseSequence(), QPatternist::XsdSchemaParser::parseSimpleContent(), QPatternist::XsdSchemaParser::parseSimpleContentExtension(), QPatternist::XsdSchemaParser::parseSimpleContentRestriction(), QPatternist::XsdSchemaParser::parseSimpleRestriction(), QPatternist::XsdSchemaParser::parseTotalDigitsFacet(), QPatternist::XsdSchemaParser::parseUnion(), QPatternist::XsdSchemaParser::parseUnique(), QPatternist::XsdSchemaParser::parseWhiteSpaceFacet(), QPatternist::AccelTreeResourceLoader::streamToReceiver(), and QXmlStreamWriter::writeCurrentToken().

2273 {
2274  Q_D(const QXmlStreamReader);
2275  return d->namespaceUri;
2276 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ notationDeclarations()

QXmlStreamNotationDeclarations QXmlStreamReader::notationDeclarations ( ) const

If the state() is DTD , this function returns the DTD's notation declarations.

Otherwise an empty vector is returned.

The QXmlStreamNotationDeclarations class is defined to be a QVector of QXmlStreamNotationDeclaration.

Definition at line 2002 of file qxmlstream.cpp.

2003 {
2004  Q_D(const QXmlStreamReader);
2005  if (d->notationDeclarations.size())
2006  const_cast<QXmlStreamReaderPrivate *>(d)->resolveDtd();
2007  return d->publicNotationDeclarations;
2008 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ prefix()

QStringRef QXmlStreamReader::prefix ( ) const

Returns the prefix of a StartElement or EndElement.

Since
4.4
See also
name(), qualifiedName()

Definition at line 2308 of file qxmlstream.cpp.

Referenced by QPatternist::AccelTreeResourceLoader::streamToReceiver().

2309 {
2310  Q_D(const QXmlStreamReader);
2311  return d->prefix;
2312 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ processingInstructionData()

QStringRef QXmlStreamReader::processingInstructionData ( ) const

Returns the data of a ProcessingInstruction.

Definition at line 2248 of file qxmlstream.cpp.

Referenced by QSvgHandler::parse(), QPatternist::AccelTreeResourceLoader::streamToReceiver(), and QXmlStreamWriter::writeCurrentToken().

2249 {
2250  Q_D(const QXmlStreamReader);
2251  return d->processingInstructionData;
2252 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ processingInstructionTarget()

QStringRef QXmlStreamReader::processingInstructionTarget ( ) const

Returns the target of a ProcessingInstruction.

Definition at line 2239 of file qxmlstream.cpp.

Referenced by QSvgHandler::parse(), QPatternist::AccelTreeResourceLoader::streamToReceiver(), and QXmlStreamWriter::writeCurrentToken().

2240 {
2241  Q_D(const QXmlStreamReader);
2242  return d->processingInstructionTarget;
2243 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ qualifiedName()

QStringRef QXmlStreamReader::qualifiedName ( ) const

Returns the qualified name of a StartElement or EndElement;.

A qualified name is the raw name of an element in the XML data. It consists of the namespace prefix, followed by colon, followed by the element's local name. Since the namespace prefix is not unique (the same prefix can point to different namespaces and different prefixes can point to the same namespace), you shouldn't use qualifiedName(), but the resolved namespaceUri() and the attribute's local name().

See also
name(), prefix(), namespaceUri()

Definition at line 2290 of file qxmlstream.cpp.

Referenced by QPatternist::XSLTTokenizer::insideSequenceConstructor().

2291 {
2292  Q_D(const QXmlStreamReader);
2293  return d->qualifiedName;
2294 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ raiseError()

void QXmlStreamReader::raiseError ( const QString message = QString())

Raises a custom error with an optional error message.

See also
error(), errorString()

Definition at line 2205 of file qxmlstream.cpp.

2206 {
2208  d->raiseError(CustomError, message);
2209 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ readElementText() [1/2]

QString QXmlStreamReader::readElementText ( ReadElementTextBehaviour  behaviour)

Convenience function to be called in case a StartElement was read.

Reads until the corresponding EndElement and returns all text in-between. In case of no error, the current token (see tokenType()) after having called this function is EndElement.

The function concatenates text() when it reads either Characters or EntityReference tokens, but skips ProcessingInstruction and Comment . If the current token is not StartElement, an empty string is returned.

The behaviour defines what happens in case anything else is read before reaching EndElement. The function can include the text from child elements (useful for example for HTML), ignore child elements, or raise an UnexpectedElementError and return what was read so far.

Since
4.6

Definition at line 2151 of file qxmlstream.cpp.

2152 {
2154  if (isStartElement()) {
2155  QString result;
2156  forever {
2157  switch (readNext()) {
2158  case Characters:
2159  case EntityReference:
2160  result.insert(result.size(), d->text.unicode(), d->text.size());
2161  break;
2162  case EndElement:
2163  return result;
2164  case ProcessingInstruction:
2165  case Comment:
2166  break;
2167  case StartElement:
2168  if (behaviour == SkipChildElements) {
2170  break;
2171  } else if (behaviour == IncludeChildElements) {
2172  result += readElementText(behaviour);
2173  break;
2174  }
2175  // Fall through (for ErrorOnUnexpectedElement)
2176  default:
2177  if (d->error || behaviour == ErrorOnUnexpectedElement) {
2178  if (!d->error)
2179  d->raiseError(UnexpectedElementError, QXmlStream::tr("Expected character data."));
2180  return result;
2181  }
2182  }
2183  }
2184  }
2185  return QString();
2186 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
void skipCurrentElement()
Reads until the end of the current element, skipping any child nodes.
Definition: qxmlstream.cpp:706
bool isStartElement() const
Returns true if tokenType() equals StartElement ; otherwise returns false.
Definition: qxmlstream.h:337
TokenType readNext()
Reads the next token and returns its type.
Definition: qxmlstream.cpp:623
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290
QString readElementText()
QString & insert(int i, QChar c)
Definition: qstring.cpp:1671
#define forever
This macro is provided for convenience for writing infinite loops.
Definition: qglobal.h:2452

◆ readElementText() [2/2]

QString QXmlStreamReader::readElementText ( )

Definition at line 2196 of file qxmlstream.cpp.

◆ readNext()

QXmlStreamReader::TokenType QXmlStreamReader::readNext ( )

Reads the next token and returns its type.

With one exception, once an error() is reported by readNext(), further reading of the XML stream is not possible. Then atEnd() returns true, hasError() returns true, and this function returns QXmlStreamReader::Invalid.

The exception is when error() returns PrematureEndOfDocumentError. This error is reported when the end of an otherwise well-formed chunk of XML is reached, but the chunk doesn't represent a complete XML document. In that case, parsing can be resumed by calling addData() to add the next chunk of XML, when the stream is being read from a QByteArray, or by waiting for more data to arrive when the stream is being read from a device().

See also
tokenType(), tokenString()

Definition at line 623 of file qxmlstream.cpp.

Referenced by QPatternist::ColoringMessageHandler::colorifyDescription(), QDeclarativeXMLHttpRequest::findTextCodec(), Document::load(), QScriptXmlParser::parse(), QSvgHandler::parse(), QPatternist::MaintainingReader< XSLTTokenLookup >::readNext(), readNextStartElement(), skipCurrentElement(), QPatternist::AccelTreeResourceLoader::streamToReceiver(), and tokenUntil().

624 {
626  if (d->type != Invalid) {
627  if (!d->hasCheckedStartDocument)
628  if (!d->checkStartDocument())
629  return d->type; // synthetic StartDocument or error
630  d->parse();
631  if (d->atEnd && d->type != EndDocument && d->type != Invalid)
632  d->raiseError(PrematureEndOfDocumentError);
633  else if (!d->atEnd && d->type == EndDocument)
634  d->raiseWellFormedError(QXmlStream::tr("Extra content at end of document."));
635  } else if (d->error == PrematureEndOfDocumentError) {
636  // resume error
637  d->type = NoToken;
638  d->atEnd = false;
639  d->token = -1;
640  return readNext();
641  }
642  return d->type;
643 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
TokenType readNext()
Reads the next token and returns its type.
Definition: qxmlstream.cpp:623
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ readNextStartElement()

bool QXmlStreamReader::readNextStartElement ( )

Reads until the next start element within the current element.

Returns true when a start element was reached. When the end element was reached, or when an error occurred, false is returned.

The current element is the element matching the most recently parsed start element of which a matching end element has not yet been reached. When the parser has reached the end element, the current element becomes the parent element.

You can traverse a document by repeatedly calling this function while ensuring that the stream reader is not at the end of the document:

QXmlStreamReader xs(&file);
while (!xs.atEnd()) {
if (xs.readNextStartElement())
std::cout << qPrintable(xs.name().toString()) << std::endl;
}

This is a convenience function for when you're only concerned with parsing XML elements. The QXmlStream Bookmarks Example makes extensive use of this function.

Since
4.6
See also
readNext()

Definition at line 684 of file qxmlstream.cpp.

685 {
686  while (readNext() != Invalid) {
687  if (isEndElement())
688  return false;
689  else if (isStartElement())
690  return true;
691  }
692  return false;
693 }
bool isEndElement() const
Returns true if tokenType() equals EndElement ; otherwise returns false.
Definition: qxmlstream.h:338
bool isStartElement() const
Returns true if tokenType() equals StartElement ; otherwise returns false.
Definition: qxmlstream.h:337
TokenType readNext()
Reads the next token and returns its type.
Definition: qxmlstream.cpp:623

◆ setDevice()

void QXmlStreamReader::setDevice ( QIODevice device)

Sets the current device to device.

Setting the device resets the stream to its initial state.

See also
device(), clear()

Definition at line 489 of file qxmlstream.cpp.

Referenced by QSvgIOHandlerPrivate::load(), and QXmlStreamReader().

490 {
492  if (d->deleteDevice) {
493  delete d->device;
494  d->deleteDevice = false;
495  }
496  d->device = device;
497  d->init();
498 
499 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QIODevice * device() const
Returns the current device associated with the QXmlStreamReader, or 0 if no device has been assigned...
Definition: qxmlstream.cpp:507
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ setEntityResolver()

void QXmlStreamReader::setEntityResolver ( QXmlStreamEntityResolver resolver)

Makes resolver the new entityResolver().

Since
4.4

The stream reader does not take ownership of the resolver. It's the callers responsibility to ensure that the resolver is valid during the entire life-time of the stream reader object, or until another resolver or 0 is set.

See also
entityResolver()

Definition at line 248 of file qxmlstream.cpp.

249 {
251  d->entityResolver = resolver;
252 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ setNamespaceProcessing()

void QXmlStreamReader::setNamespaceProcessing ( bool  enable)

Definition at line 782 of file qxmlstream.cpp.

Referenced by QSvgHandler::parse().

783 {
785  d->namespaceProcessing = enable;
786 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ skipCurrentElement()

void QXmlStreamReader::skipCurrentElement ( )

Reads until the end of the current element, skipping any child nodes.

This function is useful for skipping unknown elements.

The current element is the element matching the most recently parsed start element of which a matching end element has not yet been reached. When the parser has reached the end element, the current element becomes the parent element.

Since
4.6

Definition at line 706 of file qxmlstream.cpp.

707 {
708  int depth = 1;
709  while (depth && readNext() != Invalid) {
710  if (isEndElement())
711  --depth;
712  else if (isStartElement())
713  ++depth;
714  }
715 }
bool isEndElement() const
Returns true if tokenType() equals EndElement ; otherwise returns false.
Definition: qxmlstream.h:338
bool isStartElement() const
Returns true if tokenType() equals StartElement ; otherwise returns false.
Definition: qxmlstream.h:337
TokenType readNext()
Reads the next token and returns its type.
Definition: qxmlstream.cpp:623

◆ text()

QStringRef QXmlStreamReader::text ( ) const

Returns the text of Characters , Comment , DTD , or EntityReference.

Definition at line 1989 of file qxmlstream.cpp.

Referenced by QPatternist::ColoringMessageHandler::colorifyDescription(), QPatternist::XSLTTokenizer::insideSequenceConstructor(), Document::load(), QScriptXmlParser::parse(), QSvgHandler::parse(), QPatternist::XsdSchemaParser::parseNotation(), QPatternist::XSLTTokenizer::readElementText(), QPatternist::AccelTreeResourceLoader::streamToReceiver(), and QXmlStreamWriter::writeCurrentToken().

1990 {
1991  Q_D(const QXmlStreamReader);
1992  return d->text;
1993 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

◆ tokenString()

QString QXmlStreamReader::tokenString ( ) const

Returns the reader's current token as string.

See also
tokenType()

Definition at line 798 of file qxmlstream.cpp.

799 {
800  Q_D(const QXmlStreamReader);
803 }
double d
Definition: qnumeric_p.h:62
static const char QXmlStreamReader_tokenTypeString_string[]
Definition: qxmlstream.cpp:749
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290
static const short QXmlStreamReader_tokenTypeString_indices[]
Definition: qxmlstream.cpp:762

◆ tokenType()

QXmlStreamReader::TokenType QXmlStreamReader::tokenType ( ) const

Returns the type of the current token.

The current token can also be queried with the convenience functions isStartDocument(), isEndDocument(), isStartElement(), isEndElement(), isCharacters(), isComment(), isDTD(), isEntityReference(), and isProcessingInstruction().

See also
tokenString()

Definition at line 656 of file qxmlstream.cpp.

Referenced by QPatternist::ColoringMessageHandler::colorifyDescription(), QPatternist::XSLTTokenizer::handleStandardAttributes(), QPatternist::XSLTTokenizer::handleValidationAttributes(), QPatternist::XSLTTokenizer::insideChoose(), QPatternist::XSLTTokenizer::insideSequenceConstructor(), QPatternist::XSLTTokenizer::insideTemplate(), QPatternist::XSLTTokenizer::isElement(), QPatternist::XSLTTokenizer::isStylesheetElement(), QPatternist::XSLTTokenizer::isXSLT(), QPatternist::XSLTTokenizer::parseFallbacksOnly(), QPatternist::XSLTTokenizer::queueNamespaceDeclarations(), QPatternist::XSLTTokenizer::queueParams(), QPatternist::XSLTTokenizer::queueSelectOrSequenceConstructor(), QPatternist::XSLTTokenizer::queueSorting(), QPatternist::XSLTTokenizer::queueVariableDeclaration(), QPatternist::XSLTTokenizer::queueWithParams(), QPatternist::XSLTTokenizer::skipBodyOfParam(), QPatternist::AccelTreeResourceLoader::streamToReceiver(), QPatternist::XSLTTokenizer::unexpectedContent(), and QXmlStreamWriter::writeCurrentToken().

657 {
658  Q_D(const QXmlStreamReader);
659  return d->type;
660 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QXmlStreamReader class provides a fast parser for reading well-formed XML via a simple streaming ...
Definition: qxmlstream.h:290

Properties

◆ d_ptr

QScopedPointer<QXmlStreamReaderPrivate> QXmlStreamReader::d_ptr
private

Definition at line 407 of file qxmlstream.h.


The documentation for this class was generated from the following files: