QXmlReader Class
La classe QXmlReader fornisce un'interfaccia per i lettori XML (ovvero i parser). Per saperne di più...
| Intestazione: | #include <QXmlReader> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core5Compat) target_link_libraries(mytarget PRIVATE Qt6::Core5Compat) |
| qmake: | QT += core5compat |
| Ereditato da: |
Nota: Tutte le funzioni di questa classe sono rientranti.
Funzioni pubbliche
| virtual | ~QXmlReader() |
| virtual QXmlDTDHandler * | DTDHandler() const = 0 |
| virtual QXmlContentHandler * | contentHandler() const = 0 |
| virtual QXmlDeclHandler * | declHandler() const = 0 |
| virtual QXmlEntityResolver * | entityResolver() const = 0 |
| virtual QXmlErrorHandler * | errorHandler() const = 0 |
| virtual bool | feature(const QString &name, bool *ok = nullptr) const = 0 |
| virtual bool | hasFeature(const QString &name) const = 0 |
| virtual bool | hasProperty(const QString &name) const = 0 |
| virtual QXmlLexicalHandler * | lexicalHandler() const = 0 |
| virtual bool | parse(const QXmlInputSource *input) = 0 |
| virtual void * | property(const QString &name, bool *ok = nullptr) const = 0 |
| virtual void | setContentHandler(QXmlContentHandler *handler) = 0 |
| virtual void | setDTDHandler(QXmlDTDHandler *handler) = 0 |
| virtual void | setDeclHandler(QXmlDeclHandler *handler) = 0 |
| virtual void | setEntityResolver(QXmlEntityResolver *handler) = 0 |
| virtual void | setErrorHandler(QXmlErrorHandler *handler) = 0 |
| virtual void | setFeature(const QString &name, bool value) = 0 |
| virtual void | setLexicalHandler(QXmlLexicalHandler *handler) = 0 |
| virtual void | setProperty(const QString &name, void *value) = 0 |
Descrizione dettagliata
Questa classe astratta fornisce un'interfaccia per tutti i lettori XML di Qt. Attualmente nel modulo Qt XML è inclusa una sola implementazione di un lettore: QXmlSimpleReader. Nelle versioni future potrebbero essere disponibili altri lettori con proprietà diverse (ad esempio un parser di validazione).
Il design delle classi XML segue l'interfaccia Java SAX2, con i nomi adattati alle convenzioni di denominazione di Qt. Per chiunque abbia già lavorato con SAX2 dovrebbe essere molto semplice iniziare a utilizzare le classi Qt XML.
Tutti i lettori utilizzano la classe ` QXmlInputSource ` per leggere il documento di input. Poiché solitamente si è interessati a contenuti specifici all’interno del documento XML, il lettore riporta tali contenuti tramite speciali classi di gestore (`QXmlDTDHandler`, ` QXmlDeclHandler`, ` QXmlContentHandler`, ` QXmlEntityResolver`, ` QXmlErrorHandler ` e ` QXmlLexicalHandler`), di cui è necessario creare una sottoclasse se si desidera elaborare i contenuti.
Poiché le classi di gestione descrivono solo interfacce, è necessario implementare tutte le funzioni. Per semplificare questa operazione, mettiamo a disposizione la classe ` QXmlDefaultHandler `: essa implementa un comportamento predefinito (non fare nulla) per tutte le funzioni, consentendo di crearne una sottoclasse e di implementare solo le funzioni di interesse.
Le caratteristiche e le proprietà del lettore possono essere impostate rispettivamente con ` setFeature()` e ` setProperty()`. È possibile configurare il lettore affinché utilizzi le proprie sottoclassi tramite ` setEntityResolver()`, ` setDTDHandler()`, ` setContentHandler()`, ` setErrorHandler()`, ` setLexicalHandler()` e ` setDeclHandler()`. L’analisi stessa viene avviata con una chiamata a ` parse()`.
Si noti che questa classe è ora deprecata; si prega di utilizzare QXmlStreamReader o QDomDocument per la lettura dei file XML.
Vedi anche QXmlSimpleReader.
Documentazione delle funzioni membro
[virtual noexcept] QXmlReader::~QXmlReader()
Distrugge il lettore.
[pure virtual] QXmlDTDHandler *QXmlReader::DTDHandler() const
Restituisce il gestore DTD o ` nullptr ` se non ne è stato impostato alcuno.
Vedi anche setDTDHandler().
[pure virtual] QXmlContentHandler *QXmlReader::contentHandler() const
Restituisce il gestore dei contenuti oppure nullptr se non ne è stato impostato alcuno.
Vedi anche setContentHandler().
[pure virtual] QXmlDeclHandler *QXmlReader::declHandler() const
Restituisce il gestore delle dichiarazioni oppure nullptr se non ne è stato impostato alcuno.
Vedi anche setDeclHandler().
[pure virtual] QXmlEntityResolver *QXmlReader::entityResolver() const
Restituisce il resolver dell'entità oppure nullptr se non ne è stato impostato alcuno.
Vedi anche setEntityResolver().
[pure virtual] QXmlErrorHandler *QXmlReader::errorHandler() const
Restituisce il gestore degli errori o nullptr se non ne è stato impostato alcuno.
Vedi anche setErrorHandler().
[pure virtual] bool QXmlReader::feature(const QString &name, bool *ok = nullptr) const
Se il lettore dispone della caratteristica denominata “ name ”, viene restituito il valore di tale caratteristica. Se tale caratteristica non esiste, il valore restituito è indefinito.
Se ` ok ` non è ` nullptr`: *ok viene impostato su `true` se il lettore dispone della funzionalità denominata ` name`; in caso contrario, *ok viene impostato su `false`.
Vedi anche setFeature() e hasFeature().
[pure virtual] bool QXmlReader::hasFeature(const QString &name) const
Restituisce true se il lettore dispone della funzionalità denominata name; in caso contrario, restituisce false.
Vedi anche feature() e setFeature().
[pure virtual] bool QXmlReader::hasProperty(const QString &name) const
Restituisce true se il lettore possiede la proprietà name; in caso contrario, restituisce false.
Vedi anche property() e setProperty().
[pure virtual] QXmlLexicalHandler *QXmlReader::lexicalHandler() const
Restituisce l'handler lessicale o ` nullptr ` se non ne è stato impostato alcuno.
Vedi anche setLexicalHandler().
[pure virtual] bool QXmlReader::parse(const QXmlInputSource *input)
Legge un documento XML da input e lo analizza. Restituisce true se l'analisi ha avuto esito positivo; in caso contrario, restituisce false.
[pure virtual] void *QXmlReader::property(const QString &name, bool *ok = nullptr) const
Se il lettore possiede la proprietà name, questa funzione restituisce il valore della proprietà; in caso contrario, il valore restituito è indefinito.
Se ok non è nullptr: se il lettore possiede la proprietà name * ,ok viene impostato su true; altrimenti *ok viene impostato su false.
Vedi anche setProperty() e hasProperty().
[pure virtual] void QXmlReader::setContentHandler(QXmlContentHandler *handler)
Imposta il gestore dei contenuti su handler.
Vedi anche contentHandler().
[pure virtual] void QXmlReader::setDTDHandler(QXmlDTDHandler *handler)
Imposta il gestore DTD su handler.
Vedi anche DTDHandler().
[pure virtual] void QXmlReader::setDeclHandler(QXmlDeclHandler *handler)
Imposta il gestore delle dichiarazioni su handler.
Vedi anche declHandler().
[pure virtual] void QXmlReader::setEntityResolver(QXmlEntityResolver *handler)
Imposta il resolver di entità su handler.
Vedi anche entityResolver().
[pure virtual] void QXmlReader::setErrorHandler(QXmlErrorHandler *handler)
Imposta il gestore degli errori su handler. Cancella il gestore degli errori se handler è pari a 0.
Vedi anche errorHandler().
[pure virtual] void QXmlReader::setFeature(const QString &name, bool value)
Imposta la funzionalità denominata " name " sul valore specificato value. Se il lettore non dispone di tale funzionalità, non accade nulla.
Vedi anche feature() e hasFeature().
[pure virtual] void QXmlReader::setLexicalHandler(QXmlLexicalHandler *handler)
Imposta il gestore lessicale su handler.
Vedi anche lexicalHandler().
[pure virtual] void QXmlReader::setProperty(const QString &name, void *value)
Imposta la proprietà name su value. Se il lettore non dispone di tale proprietà, non accade nulla.
Vedi anche ` property()` e ` hasProperty()`.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.