Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Fonctions  · 

QXmlInputSource Class Reference
[XML module]

The QXmlInputSource class provides the input data for the QXmlReader subclasses. More...

#include <qxml.h>

List of all member functions.

Public Members

Protected Members

  • virtual QString fromRawData ( const QByteArray & data, bool beginning = FALSE )

Detailed Description

The QXmlInputSource class provides the input data for the QXmlReader subclasses.

All subclasses of QXmlReader read the input XML document from this class.

This class recognizes the encoding of the data by reading the encoding declaration in the XML file if it finds one, and reading the data using the corresponding encoding. If it does not find an encoding declaration, then it assumes that the data is either in UTF-8 or UTF-16, depending on whether it can find a byte-order mark.

There are two ways to populate the input source with data: you can construct it with a QIODevice* so that the input source reads the data from that device. Or you can set the data explicitly with one of the setData() functions.

Usually you either construct a QXmlInputSource that works on a QIODevice* or you construct an empty QXmlInputSource and set the data with setData(). There are only rare occasions where you would want to mix both methods.

The QXmlReader subclasses use the next() function to read the input character by character. If you want to start from the beginning again, use reset().

The functions data() and fetchData() are useful if you want to do something with the data other than parsing, e.g. displaying the raw XML file. The benefit of using the QXmlInputClass in such cases is that it tries to use the correct encoding.

See also QXmlReader, QXmlSimpleReader, and XML.


Member Function Documentation

QXmlInputSource::QXmlInputSource ()

Constructs an input source which contains no data.

See also setData().

QXmlInputSource::QXmlInputSource ( QIODevice * dev )

Constructs an input source and gets the data from device dev. If dev is not open, it is opened in read-only mode. If dev is 0 or it is not possible to read from the device, the input source will contain no data.

See also setData(), fetchData(), and QIODevice.

QXmlInputSource::QXmlInputSource ( QFile & file )

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Constructs an input source and gets the data from the file file. If the file cannot be read the input source is empty.

QXmlInputSource::QXmlInputSource ( QTextStream & stream )

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Constructs an input source and gets the data from the text stream stream.

QXmlInputSource::~QXmlInputSource () [virtual]

Destructor.

QString QXmlInputSource::data () [virtual]

Returns the data the input source contains or QString::null if the input source does not contain any data.

See also setData(), QXmlInputSource(), and fetchData().

void QXmlInputSource::fetchData () [virtual]

This function reads more data from the device that was set during construction. If the input source already contained data, this function deletes that data first.

This object contains no data after a call to this function if the object was constructed without a device to read data from or if this function was not able to get more data from the device.

There are two occasions where a fetch is done implicitly by another function call: during construction (so that the object starts out with some initial data where available), and during a call to next() (if the data had run out).

You don't normally need to use this function if you use next().

See also data(), next(), and QXmlInputSource().

QString QXmlInputSource::fromRawData ( const QByteArray & data, bool beginning = FALSE ) [virtual protected]

This function reads the XML file from data and tries to recognize the encoding. It converts the raw data data into a QString and returns it. It tries its best to get the correct encoding for the XML file.

If beginning is TRUE, this function assumes that the data starts at the beginning of a new XML document and looks for an encoding declaration. If beginning is FALSE, it converts the raw data using the encoding determined from prior calls.

QChar QXmlInputSource::next () [virtual]

Returns the next character of the input source. If this function reaches the end of available data, it returns QXmlInputSource::EndOfData. If you call next() after that, it tries to fetch more data by calling fetchData(). If the fetchData() call results in new data, this function returns the first character of that data; otherwise it returns QXmlInputSource::EndOfDocument.

See also reset(), fetchData(), QXmlSimpleReader::parse(), and QXmlSimpleReader::parseContinue().

void QXmlInputSource::reset () [virtual]

This function sets the position used by next() to the beginning of the data returned by data(). This is useful if you want to use the input source for more than one parse.

See also next().

Example: xml/tagreader-with-features/tagreader.cpp.

void QXmlInputSource::setData ( const QString & dat ) [virtual]

Sets the data of the input source to dat.

If the input source already contains data, this function deletes that data first.

See also data().

void QXmlInputSource::setData ( const QByteArray & dat ) [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

The data dat is passed through the correct text-codec, before it is set.


This file is part of the Qt toolkit. Copyright © 1995-2003 Trolltech. All Rights Reserved.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 42
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 7
Page suivante

Le blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 3.2
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web