📄 qxml.cpp
字号:
If this function returns FALSE the reader will stop parsing and will report an error. The reader will use the function errorString() to get the error message that will be used for reporting the error.*//*! \fn bool QXmlDeclHandler::externalEntityDecl( const QString& name, const QString& publicId, const QString& systemId ) The reader calls this function to report a parsed external entity declaration. Only the effective (first) declaration for each entity will be reported. If this function returns FALSE the reader will stop parsing and will report an error. The reader will use the function errorString() to get the error message that will be used for reporting the error.*//*! \fn QString QXmlDeclHandler::errorString() The reader calls this function to get an error string if any of the handler functions returns FALSE to him.*//*! \class QXmlDefaultHandler qxml.h \brief The QXmlDefaultHandler class provides a default implementation of all XML handler classes. \module XML Very often you are only interested in parts of the things that that the reader reports to you. This class simply implements a default behaviour of the handler classes (most of the time: do nothing). Normally this is the class you subclass for implementing your customized handler. See also the <a href="xml.html#introSAX2">Introduction to SAX2</a>. \sa QXmlDTDHandler QXmlDeclHandler QXmlContentHandler QXmlEntityResolver QXmlErrorHandler QXmlLexicalHandler*//*! \fn QXmlDefaultHandler::QXmlDefaultHandler() Constructor.*//*! \fn QXmlDefaultHandler::~QXmlDefaultHandler() Destructor.*//*! Does nothing.*/void QXmlDefaultHandler::setDocumentLocator( QXmlLocator* ){}/*! Does nothing.*/bool QXmlDefaultHandler::startDocument(){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::endDocument(){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::startPrefixMapping( const QString&, const QString& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::endPrefixMapping( const QString& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::startElement( const QString&, const QString&, const QString&, const QXmlAttributes& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::endElement( const QString&, const QString&, const QString& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::characters( const QString& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::ignorableWhitespace( const QString& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::processingInstruction( const QString&, const QString& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::skippedEntity( const QString& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::warning( const QXmlParseException& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::error( const QXmlParseException& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::fatalError( const QXmlParseException& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::notationDecl( const QString&, const QString&, const QString& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::unparsedEntityDecl( const QString&, const QString&, const QString&, const QString& ){ return TRUE;}/*! Always sets \a ret to 0, so that the reader will use the system identifier provided in the XML document.*/bool QXmlDefaultHandler::resolveEntity( const QString&, const QString&, QXmlInputSource* ret ){ ret = 0; return TRUE;}/*! Returns the default error string.*/QString QXmlDefaultHandler::errorString(){ return QString( XMLERR_ERRORBYCONSUMER );}/*! Does nothing.*/bool QXmlDefaultHandler::startDTD( const QString&, const QString&, const QString& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::endDTD(){ return TRUE;}#if 0/*! Does nothing.*/bool QXmlDefaultHandler::startEntity( const QString& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::endEntity( const QString& ){ return TRUE;}#endif/*! Does nothing.*/bool QXmlDefaultHandler::startCDATA(){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::endCDATA(){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::comment( const QString& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::attributeDecl( const QString&, const QString&, const QString&, const QString&, const QString& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::internalEntityDecl( const QString&, const QString& ){ return TRUE;}/*! Does nothing.*/bool QXmlDefaultHandler::externalEntityDecl( const QString&, const QString&, const QString& ){ return TRUE;}/********************************************* * * QXmlSimpleReaderPrivate * *********************************************/class QXmlSimpleReaderPrivate{private: // constructor QXmlSimpleReaderPrivate() { } // used for entity declarations struct ExternParameterEntity { ExternParameterEntity( ) {} ExternParameterEntity( const QString &p, const QString &s ) : publicId(p), systemId(s) {} QString publicId; QString systemId; }; struct ExternEntity { ExternEntity( ) {} ExternEntity( const QString &p, const QString &s, const QString &n ) : publicId(p), systemId(s), notation(n) {} QString publicId; QString systemId; QString notation; }; QMap<QString,ExternParameterEntity> externParameterEntities; QMap<QString,QString> parameterEntities; QMap<QString,ExternEntity> externEntities; QMap<QString,QString> entities; // used for standalone declaration enum Standalone { Yes, No, Unknown }; QString doctype; // only used for the doctype QString xmlVersion; // only used to store the version information QString encoding; // only used to store the encoding Standalone standalone; // used to store the value of the standalone declaration QString publicId; // used by parseExternalID() to store the public ID QString systemId; // used by parseExternalID() to store the system ID QString attDeclEName; // use by parseAttlistDecl() QString attDeclAName; // use by parseAttlistDecl() // flags for some features support bool useNamespaces; bool useNamespacePrefixes; bool reportWhitespaceCharData; // used to build the attribute list QXmlAttributes attList; // helper classes QXmlLocator *locator; QXmlNamespaceSupport namespaceSupport; // error string QString error; // friend declarations friend class QXmlSimpleReader;};/********************************************* * * QXmlSimpleReader * *********************************************//*! \class QXmlReader qxml.h \brief The QXmlReader class provides an interface for XML readers (i.e. parsers). \module XML This abstract class describes an interface for all XML readers in Qt. At the moment there is only one implementation of a reader included in the XML module of Qt (QXmlSimpleReader). In future releases there might be more readers with different properties available (e.g. a validating parser). The design of the XML classes follow the <a href="http://www.megginson.com/SAX/">SAX2 java interface</a>. It was adopted to fit into the Qt naming conventions; so it should be very easy for anybody who has worked with SAX2 to get started with the Qt XML classes. All readers use the class QXmlInputSource to read the input document from. Since you are normally interested in certain contents of the XML document, the reader reports those contents through special handler classes (QXmlDTDHandler, QXmlDeclHandler, QXmlContentHandler, QXmlEntityResolver, QXmlErrorHandler and QXmlLexicalHandler). You have to subclass these classes. Since the handler classes describe only interfaces you must implement all functions; there is a class (QXmlDefaultHandler) to make this easier; it implements a default behaviour (do nothing) for all functions. For getting started see also the <a href="xml-sax.html#quickStart">Quick start</a>. \sa QXmlSimpleReader*//*! \fn bool QXmlReader::feature( const QString& name, bool *ok ) const If the reader has the feature \a name, this function returns the value of the feature. If the reader has not the feature \a name, the return value may be anything. If \a ok is not 0, then \a ok is set to TRUE if the reader has the feature \a name, otherwise \a ok is set to FALSE. \sa setFeature() hasFeature()*//*! \fn void QXmlReader::setFeature( const QString& name, bool value ) Sets the feature \a name to \a value. If the reader has not the feature \a name, this value is ignored. \sa feature() hasFeature()*//*! \fn bool QXmlReader::hasFeature( const QString& name ) const Returns \c TRUE if the reader has the feature \a name, otherwise FALSE. \sa feature() setFeature()*//*! \fn void* QXmlReader::property( const QString& name, bool *ok ) const If the reader has the property \a name, this function returns the value of the property. If the reader has not the property \a name, the return value is 0. If \a ok is not 0, then \a ok is set to TRUE if the reader has the property \a name, otherwise \a ok is set to FALSE. \sa setProperty() hasProperty()*//*! \fn void QXmlReader::setProperty( const QString& name, void* value ) Sets the property \a name to \a value. If the reader has not the property \a name, this value is ignored. \sa property() hasProperty()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -