Описание класса QXmlInputSource [модуль QtXml]
Класс QXmlInputSource обеспечивает входные данные для подклассов QXmlReader. Далее...
#include <QXmlInputSource> Примечание: все функции в этом классе реентерабельны.
Открытые функции
Защищенные функции
- virtual QString fromRawData ( const QByteArray & data, bool beginning = false )
Подробное описание
Класс QXmlInputSource обеспечивает входные данные для подклассов QXmlReader.
Все подклассы QXmlReader читают входящий XML через этот класс.
Этот класс распознаёт кодировку данных считыванием указания кодировки в XML файле, если она там есть, и читает данные, используя полученную кодировку. Если указание кодировки не найдено, подразумевается UTF-8 или UTF-16, в зависимости от того, найден ли байт-пометка.
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.
Смотрите также QXmlReader и QXmlSimpleReader.
Описание функций-членов
QXmlInputSource::QXmlInputSource ()
Создаёт входной источник без данных.
Смотрите также setData().
QXmlInputSource::QXmlInputSource ( QIODevice * dev )
Создаёт входной источник данных и устанавливает передачу данных из устройства dev. Если dev не открыто, оно открывается в режиме "только чтение". Если dev является 0 или недоступно для чтения, входной источник не будет содержать данных.
Смотрите также setData(), fetchData() и QIODevice.
QXmlInputSource::~QXmlInputSource () [virtual]
Деструктор.
QString QXmlInputSource::data () const [virtual]
Returns the data the input source contains or an empty string 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.
Readers, such as QXmlSimpleReader, will assume that the end of the XML document has been reached if the this function returns QXmlInputSource::EndOfDocument, and will check that the supplied input is well-formed. Therefore, when reimplementing this function, it is important to ensure that this behavior is duplicated.
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.
Смотрите также next().
void QXmlInputSource::setData ( const QString & dat ) [virtual]
Устанавливает данные из входящего источника в dat.
Если входящий источник уже имеет данные, они будут предварительно удалены.
Смотрите также data().
void QXmlInputSource::setData ( const QByteArray & dat ) [virtual]
Эта перегруженная функция, предоставленная для удобства.
Данные dat до сохранение передаются через правильный текстовый кодек.
|