Qt 4.8
|
The QIODevice class is the base interface class of all I/O devices in Qt. More...
#include <qiodevice.h>
Public Types | |
enum | OpenModeFlag { NotOpen = 0x0000, ReadOnly = 0x0001, WriteOnly = 0x0002, ReadWrite = ReadOnly | WriteOnly, Append = 0x0004, Truncate = 0x0008, Text = 0x0010, Unbuffered = 0x0020 } |
This enum is used with open() to describe the mode in which a device is opened. More... | |
Signals | |
void | aboutToClose () |
This signal is emitted when the device is about to close. More... | |
void | bytesWritten (qint64 bytes) |
This signal is emitted every time a payload of data has been written to the device. More... | |
void | readChannelFinished () |
This signal is emitted when the input (reading) stream is closed in this device. More... | |
void | readyRead () |
This signal is emitted once every time new data is available for reading from the device. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Public Functions | |
virtual bool | atEnd () const |
Returns true if the current read and write position is at the end of the device (i.e. More... | |
virtual qint64 | bytesAvailable () const |
Returns the number of bytes that are available for reading. More... | |
virtual qint64 | bytesToWrite () const |
For buffered devices, this function returns the number of bytes waiting to be written. More... | |
virtual bool | canReadLine () const |
Returns true if a complete line of data can be read from the device; otherwise returns false. More... | |
virtual void | close () |
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen. More... | |
QString | errorString () const |
Returns a human-readable description of the last device error that occurred. More... | |
bool | getChar (char *c) |
Reads one character from the device and stores it in c. More... | |
bool | isOpen () const |
Returns true if the device is open; otherwise returns false. More... | |
bool | isReadable () const |
Returns true if data can be read from the device; otherwise returns false. More... | |
virtual bool | isSequential () const |
Returns true if this device is sequential; otherwise returns false. More... | |
bool | isTextModeEnabled () const |
Returns true if the Text flag is enabled; otherwise returns false. More... | |
bool | isWritable () const |
Returns true if data can be written to the device; otherwise returns false. More... | |
virtual bool | open (OpenMode mode) |
Opens the device and sets its OpenMode to mode. More... | |
OpenMode | openMode () const |
Returns the mode in which the device has been opened; i.e. More... | |
qint64 | peek (char *data, qint64 maxlen) |
Reads at most maxSize bytes from the device into data, without side effects (i. More... | |
QByteArray | peek (qint64 maxlen) |
Peeks at most maxSize bytes from the device, returning the data peeked as a QByteArray. More... | |
virtual qint64 | pos () const |
For random-access devices, this function returns the position that data is written to or read from. More... | |
bool | putChar (char c) |
Writes the character c to the device. More... | |
QIODevice () | |
Constructs a QIODevice object. More... | |
QIODevice (QObject *parent) | |
Constructs a QIODevice object with the given parent. More... | |
qint64 | read (char *data, qint64 maxlen) |
Reads at most maxSize bytes from the device into data, and returns the number of bytes read. More... | |
QByteArray | read (qint64 maxlen) |
Reads at most maxSize bytes from the device, and returns the data read as a QByteArray. More... | |
QByteArray | readAll () |
Reads all available data from the device, and returns it as a QByteArray. More... | |
qint64 | readLine (char *data, qint64 maxlen) |
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes, stores the characters in data, and returns the number of bytes read. More... | |
QByteArray | readLine (qint64 maxlen=0) |
Reads a line from the device, but no more than maxSize characters, and returns the result as a QByteArray. More... | |
virtual bool | reset () |
Seeks to the start of input for random-access devices. More... | |
virtual bool | seek (qint64 pos) |
For random-access devices, this function sets the current position to pos, returning true on success, or false if an error occurred. More... | |
void | setTextModeEnabled (bool enabled) |
If enabled is true, this function sets the Text flag on the device; otherwise the Text flag is removed. More... | |
virtual qint64 | size () const |
For open random-access devices, this function returns the size of the device. More... | |
void | ungetChar (char c) |
Puts the character c back into the device, and decrements the current position unless the position is 0. More... | |
virtual bool | waitForBytesWritten (int msecs) |
For buffered devices, this function waits until a payload of buffered written data has been written to the device and the bytesWritten() signal has been emitted, or until msecs milliseconds have passed. More... | |
virtual bool | waitForReadyRead (int msecs) |
Blocks until new data is available for reading and the readyRead() signal has been emitted, or until msecs milliseconds have passed. More... | |
qint64 | write (const char *data, qint64 len) |
Writes at most maxSize bytes of data from data to the device. More... | |
qint64 | write (const char *data) |
Writes data from a zero-terminated string of 8-bit characters to the device. More... | |
qint64 | write (const QByteArray &data) |
Writes the content of byteArray to the device. More... | |
virtual | ~QIODevice () |
The destructor is virtual, and QIODevice is an abstract base class. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
virtual bool | event (QEvent *) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Filters events if this object has been installed as an event filter for the watched object. More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Protected Functions | |
QIODevice (QIODevicePrivate &dd, QObject *parent=0) | |
virtual qint64 | readData (char *data, qint64 maxlen)=0 |
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an error occurred. More... | |
virtual qint64 | readLineData (char *data, qint64 maxlen) |
Reads up to maxSize characters into data and returns the number of characters read. More... | |
void | setErrorString (const QString &errorString) |
Sets the human readable description of the last device error that occurred to str. More... | |
void | setOpenMode (OpenMode openMode) |
Sets the OpenMode of the device to openMode. More... | |
virtual qint64 | writeData (const char *data, qint64 len)=0 |
Writes up to maxSize bytes from data to the device. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Additional Inherited Members | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QIODevice class is the base interface class of all I/O devices in Qt.
QIODevice provides both a common implementation and an abstract interface for devices that support reading and writing of blocks of data, such as QFile, QBuffer and QTcpSocket. QIODevice is abstract and can not be instantiated, but it is common to use the interface it defines to provide device-independent I/O features. For example, Qt's XML classes operate on a QIODevice pointer, allowing them to be used with various devices (such as files and buffers).
Before accessing the device, open() must be called to set the correct OpenMode (such as ReadOnly or ReadWrite). You can then write to the device with write() or putChar(), and read by calling either read(), readLine(), or readAll(). Call close() when you are done with the device.
QIODevice distinguishes between two types of devices: random-access devices and sequential devices.
Random-access devices support seeking to arbitrary positions using seek(). The current position in the file is available by calling pos(). QFile and QBuffer are examples of random-access devices.
You can use isSequential() to determine the type of device.
QIODevice emits readyRead() when new data is available for reading; for example, if new data has arrived on the network or if additional data is appended to a file that you are reading from. You can call bytesAvailable() to determine the number of bytes that are currently available for reading. It's common to use bytesAvailable() together with the readyRead() signal when programming with asynchronous devices such as QTcpSocket, where fragments of data can arrive at arbitrary points in time. QIODevice emits the bytesWritten() signal every time a payload of data has been written to the device. Use bytesToWrite() to determine the current amount of data waiting to be written.
Certain subclasses of QIODevice, such as QTcpSocket and QProcess, are asynchronous. This means that I/O functions such as write() or read() always return immediately, while communication with the device itself may happen when control goes back to the event loop. QIODevice provides functions that allow you to force these operations to be performed immediately, while blocking the calling thread and without entering the event loop. This allows QIODevice subclasses to be used without an event loop, or in a separate thread:
waitForReadyRead() - This function suspends operation in the calling thread until new data is available for reading.
waitForBytesWritten() - This function suspends operation in the calling thread until one payload of data has been written to the device.
Calling these functions from the main, GUI thread, may cause your user interface to freeze. Example:
By subclassing QIODevice, you can provide the same interface to your own I/O devices. Subclasses of QIODevice are only required to implement the protected readData() and writeData() functions. QIODevice uses these functions to implement all its convenience functions, such as getChar(), readLine() and write(). QIODevice also handles access control for you, so you can safely assume that the device is opened in write mode if writeData() is called.
Some subclasses, such as QFile and QTcpSocket, are implemented using a memory buffer for intermediate storing of data. This reduces the number of required device accessing calls, which are often very slow. Buffering makes functions like getChar() and putChar() fast, as they can operate on the memory buffer instead of directly on the device itself. Certain I/O operations, however, don't work well with a buffer. For example, if several users open the same device and read it character by character, they may end up reading the same data when they meant to read a separate chunk each. For this reason, QIODevice allows you to bypass any buffering by passing the Unbuffered flag to open(). When subclassing QIODevice, remember to bypass any buffer you may use when the device is open in Unbuffered mode.
Definition at line 66 of file qiodevice.h.
This enum is used with open() to describe the mode in which a device is opened.
It is also returned by openMode().
Certain flags, such as Unbuffered
and Truncate
, are meaningless when used with some subclasses. Some of these restrictions are implied by the type of device that is represented by a subclass. In other cases, the restriction may be due to the implementation, or may be imposed by the underlying platform; for example, QTcpSocket does not support Unbuffered
mode, and limitations in the native API prevent QFile from supporting Unbuffered
on Windows.
Enumerator | |
---|---|
NotOpen | |
ReadOnly | |
WriteOnly | |
ReadWrite | |
Append | |
Truncate | |
Text | |
Unbuffered |
Definition at line 75 of file qiodevice.h.
QIODevice::QIODevice | ( | ) |
Constructs a QIODevice object.
Definition at line 390 of file qiodevice.cpp.
Referenced by QIODevicePrivate::~QIODevicePrivate().
|
explicit |
Constructs a QIODevice object with the given parent.
Definition at line 404 of file qiodevice.cpp.
|
virtual |
|
protected |
Definition at line 414 of file qiodevice.cpp.
|
signal |
This signal is emitted when the device is about to close.
Connect this signal if you have operations that need to be performed before the device closes (e.g., if you have data in a separate buffer that needs to be written to the device).
Referenced by close(), QProcess::close(), and QPatternist::QIODeviceDelegate::QIODeviceDelegate().
|
virtual |
Returns true if the current read and write position is at the end of the device (i.e.
there is no more data available for reading on the device); otherwise returns false.
For some devices, atEnd() can return true even though there is more data to read. This special case only applies to devices that generate data in direct response to you calling read() (e.g., /dev
or /proc
files on Unix and Mac OS X, or console input / stdin
on all platforms).
Reimplemented in QAuthDevice, QProcess, QByteDeviceWrappingIoDevice, QAbstractSocket, QFile, QHttpMultiPartIODevice, QSslSocket, QBuffer, and QPatternist::QIODeviceDelegate.
Definition at line 711 of file qiodevice.cpp.
Referenced by QNetworkReplyImplPrivate::_q_copyReadyRead(), QPatternist::QIODeviceDelegate::atEnd(), QBuffer::atEnd(), QSslSocket::atEnd(), QDataStream::atEnd(), QAbstractSocket::atEnd(), QProcess::atEnd(), QPSPrintEnginePrivate::emitPages(), QPdf::ByteStream::operator<<(), QHttpPrivate::postMoreData(), QPdf::ByteStream::prepareBuffer(), qt_read_dibv5(), read_dib_body(), QNonContiguousByteDeviceIoDeviceImpl::readPointer(), QTextStreamPrivate::scan(), QFile::symLinkTarget(), QNetworkDiskCache::updateMetaData(), and QPdfEnginePrivate::writeCompressed().
|
virtual |
Returns the number of bytes that are available for reading.
This function is commonly used with sequential devices to determine the number of bytes to allocate in a buffer before reading.
Subclasses that reimplement this function must call the base implementation in order to include the size of QIODevices' buffer. Example:
Reimplemented in QAuthDevice, QProcess, QUnixSocket, QAbstractSocket, QHttpMultiPartIODevice, QSslSocket, QLocalSocket, QNetworkReplyImpl, QNetworkReplyFileImpl, QNetworkReplyDataImpl, QPatternist::QIODeviceDelegate, and QOstDevice.
Definition at line 752 of file qiodevice.cpp.
Referenced by QNetworkReplyImplPrivate::_q_bufferOutgoingData(), QNetworkReplyImplPrivate::_q_copyReadyRead(), QLocalSocketPrivate::_q_pipeClosed(), atEnd(), QFile::atEnd(), QPatternist::QIODeviceDelegate::bytesAvailable(), QNetworkReplyDataImpl::bytesAvailable(), QNetworkReplyFileImpl::bytesAvailable(), QNetworkReplyImpl::bytesAvailable(), QLocalSocket::bytesAvailable(), QSslSocket::bytesAvailable(), QAbstractSocket::bytesAvailable(), QUnixSocket::bytesAvailable(), QProcess::bytesAvailable(), qws_read_command(), qws_read_uint(), QWSClient::readMoreCommand(), QPacketProtocolPrivate::readyToRead(), QAuthDevice::recvReadyRead(), and size().
|
virtual |
For buffered devices, this function returns the number of bytes waiting to be written.
For devices with no buffer, this function returns 0.
Reimplemented in QAuthDevice, QProcess, QUnixSocket, QHttpMultiPartIODevice, QAbstractSocket, QSslSocket, QLocalSocket, and QPatternist::QIODeviceDelegate.
Definition at line 767 of file qiodevice.cpp.
Referenced by QPatternist::QIODeviceDelegate::bytesToWrite().
|
signal |
This signal is emitted every time a payload of data has been written to the device.
The bytes argument is set to the number of bytes that were written in this payload.
bytesWritten() is not emitted recursively; if you reenter the event loop or call waitForBytesWritten() inside a slot connected to the bytesWritten() signal, the signal will not be reemitted (although waitForBytesWritten() may still return true).
Referenced by QAuthDevice::QAuthDevice(), QPatternist::QIODeviceDelegate::QIODeviceDelegate(), QAuthDevice::targetBytesWritten(), QUnixSocket::waitForBytesWritten(), QUnixSocketPrivate::writeActivated(), QOstDevice::writeData(), QAbstractSocket::writeData(), and QUdpSocket::writeDatagram().
|
virtual |
Returns true if a complete line of data can be read from the device; otherwise returns false.
Note that unbuffered devices, which have no way of determining what can be read, always return false.
This function is often called in conjunction with the readyRead() signal.
Subclasses that reimplement this function must call the base implementation in order to include the contents of the QIODevice's buffer. Example:
Reimplemented in QProcess, QUnixSocket, QAbstractSocket, QSslSocket, QLocalSocket, QBuffer, QNetworkReplyImpl, and QPatternist::QIODeviceDelegate.
Definition at line 1330 of file qiodevice.cpp.
Referenced by QLocalSocketPrivate::_q_pipeClosed(), QPatternist::QIODeviceDelegate::canReadLine(), QNetworkReplyImpl::canReadLine(), QBuffer::canReadLine(), QLocalSocket::canReadLine(), QSslSocket::canReadLine(), QAbstractSocket::canReadLine(), and QProcess::canReadLine().
|
virtual |
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
The error string is also reset.
Reimplemented in QProcess, QAbstractSocket, QFile, QUnixSocket, QHttpMultiPartIODevice, QSslSocket, QNetworkReply, QLocalSocket, QBuffer, QNetworkReplyImpl, QPatternist::QIODeviceDelegate, QNetworkReplyFileImpl, QNetworkReplyDataImpl, and QOstDevice.
Definition at line 590 of file qiodevice.cpp.
Referenced by QLocalSocketPrivate::_q_pipeClosed(), QZipWriter::addFile(), QOstDevice::close(), QPatternist::QIODeviceDelegate::close(), QBuffer::close(), QLocalSocket::close(), QZipWriter::close(), QNetworkReply::close(), QZipReader::close(), QHttpMultiPartIODevice::close(), QFile::close(), QAbstractSocket::close(), QProcess::close(), QNetworkAccessCacheBackend::closeDownstreamChannel(), QPdfBaseEnginePrivate::closePrintDevice(), QAbstractSocket::disconnectFromHostImplementation(), qws_read_command(), QFile::symLinkTarget(), QTextDocumentWriter::write(), and QXmlStreamStrategy::~QXmlStreamStrategy().
QString QIODevice::errorString | ( | ) | const |
Returns a human-readable description of the last device error that occurred.
Definition at line 1671 of file qiodevice.cpp.
Referenced by QHttpNetworkConnectionChannel::_q_error(), QSslSocketPrivate::_q_errorSlot(), QHttpPrivate::_q_slotError(), QSocks5SocketEngine::bind(), QSvgTinyDocument::load(), QPatternist::AccelTreeResourceLoader::load(), QDeclarativePixmapReader::networkRequestDone(), QNetworkAccessFileBackend::open(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), qt_parse_pattern(), QNetworkAccessFileBackend::readMoreFromFile(), QFile::rename(), QSocks5SocketEnginePrivate::setErrorState(), QSslSocketBackendPrivate::transmit(), QNetworkAccessFileBackend::uploadReadyReadSlot(), QAbstractSocket::waitForBytesWritten(), QAbstractSocket::waitForDisconnected(), and QAbstractSocket::waitForReadyRead().
bool QIODevice::getChar | ( | char * | c | ) |
Reads one character from the device and stores it in c.
If c is 0, the character is discarded. Returns true on success; otherwise returns false.
Definition at line 1536 of file qiodevice.cpp.
Referenced by QNonContiguousByteDeviceIoDeviceImpl::advanceReadPointer(), Tga16Reader::operator()(), Tga24Reader::operator()(), Tga32Reader::operator()(), QDataStream::operator>>(), read_dib_body(), read_pbm_int(), read_xpm_body(), QTgaFile::readImage(), and runningUnderDebugger().
bool QIODevice::isOpen | ( | ) | const |
Returns true if the device is open; otherwise returns false.
A device is open if it can be read from and/or written to. By default, this function returns false if openMode() returns NotOpen
.
Definition at line 530 of file qiodevice.cpp.
Referenced by QNetworkReplyImplPrivate::_q_copyReadyRead(), QFtpPrivate::_q_startNextCommand(), QZipWriterPrivate::addEntry(), QFile::atEnd(), QAbstractSocket::atEnd(), QProcess::atEnd(), QBuffer::canReadLine(), QImageWriter::canWrite(), QTiffPlugin::capabilities(), QICOPlugin::capabilities(), QJpegPlugin::capabilities(), QTgaPlugin::capabilities(), QMngPlugin::capabilities(), QPicturePrivate::checkFormat(), QFile::close(), QHttpPrivate::closeConn(), QTemporaryFile::createLocalFile(), QUuid::createUuid(), errorString(), QXmlInputSource::fetchData(), QTransportAuthPrivate::getClientKey(), QFile::handle(), QNetworkReplyImplPrivate::initCacheSaveDevice(), QImageReaderPrivate::initHandler(), QAbstractSocket::isValid(), QOstDevice::open(), QFile::open(), QPatternist::XsdStateMachine< XsdSchemaToken::NodeName >::outputGraph(), QNetworkAccessManagerPrivate::prepareMultipart(), QPicturePrivate::QPicturePrivate(), qt_inflateGZipDataFrom(), QXmlInputSource::QXmlInputSource(), QPictureIO::read(), QFile::rename(), QFile::resize(), QZipReaderPrivate::scanFiles(), QFile::seek(), QBuffer::setBuffer(), QBuffer::setData(), QFile::setFileName(), setTextModeEnabled(), QNetworkDiskCachePrivate::storeItem(), QConfFileSettingsPrivate::syncConfFile(), and QPictureIO::write().
bool QIODevice::isReadable | ( | ) | const |
Returns true if data can be read from the device; otherwise returns false.
Use bytesAvailable() to determine how many bytes can be read.
This is a convenience function which checks if the OpenMode of the device contains the ReadOnly flag.
Definition at line 544 of file qiodevice.cpp.
Referenced by QXmlQuery::bindVariable(), QTiffPlugin::capabilities(), QJpegPlugin::capabilities(), QTgaPlugin::capabilities(), QICOPlugin::capabilities(), QSvgPlugin::capabilities(), QMngPlugin::capabilities(), QGifPlugin::capabilities(), QPatternist::ExpressionFactory::createExpression(), QZipReader::isReadable(), QXmlSchemaPrivate::load(), QNetworkAccessManagerPrivate::prepareMultipart(), qt_inflateGZipDataFrom(), QTgaFile::QTgaFile(), qtiffReadProc(), QPatternist::AccelTreeResourceLoader::retrieveDocument(), QXmlQuery::setFocus(), setOpenMode(), QXmlQuery::setQuery(), QConfFileSettingsPrivate::syncConfFile(), and QXmlSchemaValidator::validate().
|
virtual |
Returns true if this device is sequential; otherwise returns false.
Sequential devices, as opposed to a random-access devices, have no concept of a start, an end, a size, or a current position, and they do not support seeking. You can only read from the device when it reports that data is available. The most common example of a sequential device is a network socket. On Unix, special files such as /dev/zero and fifo pipes are sequential.
Regular files, on the other hand, do support random access. They have both a size and a current position, and they also support seeking backwards and forwards in the data stream. Regular files are non-sequential.
The QIODevice implementation returns false.
Reimplemented in QtMultimediaInternal::MacInputDevice, MacOutputDevice, QAuthDevice, QProcess, QUnixSocket, QByteDeviceWrappingIoDevice, QAbstractSocket, QFile, QHttpMultiPartIODevice, QNetworkReply, QLocalSocket, QPatternist::QIODeviceDelegate, QNetworkReplyFileImpl, and QNetworkReplyDataImpl.
Definition at line 454 of file qiodevice.cpp.
Referenced by QNetworkReplyImplPrivate::_q_copyReadyRead(), QFtpPrivate::_q_startNextCommand(), QXbmHandler::canRead(), ICOReader::canRead(), createReadHandlerHelper(), QNetworkAccessManager::createRequest(), QTextStreamPrivate::fillReadBuffer(), QMoviePrivate::infoForFrame(), iod_read_fn(), QPatternist::QIODeviceDelegate::isSequential(), QHttpMultiPartIODevice::isSequential(), QPdf::ByteStream::operator<<(), QtIcoHandler::option(), QPdf::ByteStream::prepareBuffer(), QFtp::put(), QPatternist::QIODeviceDelegate::QIODeviceDelegate(), qt_term_source(), QTgaFile::QTgaFile(), QUnixSocket::read(), read_dib_body(), readLineData(), QNonContiguousByteDeviceIoDeviceImpl::readPointer(), QNetworkReplyImplPrivate::setup(), QNonContiguousByteDeviceIoDeviceImpl::size(), QDataStream::skipRawData(), and QFile::symLinkTarget().
bool QIODevice::isTextModeEnabled | ( | ) | const |
Returns true if the Text flag is enabled; otherwise returns false.
Definition at line 517 of file qiodevice.cpp.
Referenced by QTextStreamPrivate::fillReadBuffer(), and QTextStreamPrivate::flushWriteBuffer().
bool QIODevice::isWritable | ( | ) | const |
Returns true if data can be written to the device; otherwise returns false.
This is a convenience function which checks if the OpenMode of the device contains the WriteOnly flag.
Definition at line 558 of file qiodevice.cpp.
Referenced by QImageWriter::canWrite(), QTiffPlugin::capabilities(), QICOPlugin::capabilities(), QJpegPlugin::capabilities(), QXmlQuery::evaluateTo(), QZipWriter::isWritable(), qt_write_dib(), qt_write_dibv5(), QXmlSerializer::QXmlSerializer(), QBuffer::seek(), QConfFileSettingsPrivate::syncConfFile(), QTextDocumentWriter::write(), write_xpm_image(), and QTextOdfWriter::writeAll().
|
virtual |
Opens the device and sets its OpenMode to mode.
Returns true if successful; otherwise returns false. This function should be called from any reimplementations of open() or other functions that open the device.
Reimplemented in QFile, QTemporaryFile, QBuffer, and QPatternist::QIODeviceDelegate.
Definition at line 570 of file qiodevice.cpp.
Referenced by QLocalSocketPrivate::_q_pipeClosed(), QFtpPrivate::_q_startNextCommand(), QZipWriterPrivate::addEntry(), QZipWriter::addFile(), QPdf::ByteStream::ByteStream(), QImageWriter::canWrite(), QPdf::ByteStream::clear(), QSslSocket::connectToHostImplementation(), QAbstractSocket::connectToHostImplementation(), QLocalSocket::connectToServer(), QPdf::ByteStream::constructor_helper(), QXmlInputSource::fetchData(), QAudioOutputPrivate::freeBlocks(), QAudioInputPrivate::freeBlocks(), QImageReaderPrivate::initHandler(), QOstDevice::open(), QPatternist::QIODeviceDelegate::open(), QBuffer::open(), QFile::open(), QNetworkAccessManagerPrivate::prepareMultipart(), QAuthDevice::QAuthDevice(), QByteDeviceWrappingIoDevice::QByteDeviceWrappingIoDevice(), QNetworkReplyDataImpl::QNetworkReplyDataImpl(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), qt_inflateGZipDataFrom(), QZipStreamStrategy::QZipStreamStrategy(), QCacheItem::read(), QAuthDevice::recvReadyRead(), QZipReaderPrivate::scanFiles(), QLocalSocket::setSocketDescriptor(), QAbstractSocket::setSocketDescriptor(), QAudioOutputPrivate::start(), QAudioInputPrivate::start(), QProcess::start(), QFile::symLinkTarget(), QTextDocumentWriter::write(), and QTextOdfWriter::writeAll().
QIODevice::OpenMode QIODevice::openMode | ( | ) | const |
Returns the mode in which the device has been opened; i.e.
ReadOnly or WriteOnly.
Definition at line 465 of file qiodevice.cpp.
Referenced by QZipWriter::addFile(), QPacket::clear(), QZipWriter::close(), QAbstractSocket::connectToHost(), isReadable(), isWritable(), QPatternist::QIODeviceDelegate::open(), QFilePrivate::putCharHelper(), QPacket::QPacket(), QPicturePrivate::QPicturePrivate(), QZipReaderPrivate::scanFiles(), and setOpenMode().
Reads at most maxSize bytes from the device into data, without side effects (i.
e., if you call read() after peek(), you will get the same data). Returns the number of bytes read. If an error occurs, such as when attempting to peek a device opened in WriteOnly mode, this function returns -1.
0 is returned when no more data is available for reading.
Example:
Definition at line 1563 of file qiodevice.cpp.
Referenced by QHttpNetworkConnectionChannel::_q_readyRead(), QTiffHandler::canRead(), QSvgIOHandler::canRead(), QJpegHandler::canRead(), QGifHandler::canRead(), QXpmHandler::canRead(), QMngHandler::canRead(), QPpmHandler::canRead(), QPngHandler::canRead(), QBmpHandler::canRead(), QGLPixmapData::fromFile(), QHttpNetworkReplyPrivate::getChunkSize(), QSslSocketPrivate::peek(), and QSslSocketBackendPrivate::transmit().
QByteArray QIODevice::peek | ( | qint64 | maxSize | ) |
Peeks at most maxSize bytes from the device, returning the data peeked as a QByteArray.
Example:
This function has no way of reporting errors; returning an empty QByteArray() can mean either that no data was currently available for peeking, or that an error occurred.
Definition at line 1588 of file qiodevice.cpp.
|
virtual |
For random-access devices, this function returns the position that data is written to or read from.
For sequential devices or closed devices, where there is no concept of a "current position", 0 is returned.
The current read/write position of the device is maintained internally by QIODevice, so reimplementing this function is not necessary. When subclassing QIODevice, use QIODevice::seek() to notify QIODevice about changes in the device position.
Reimplemented in QFile, QBuffer, and QPatternist::QIODeviceDelegate.
Definition at line 624 of file qiodevice.cpp.
Referenced by QZipWriterPrivate::addEntry(), QTiffHandler::canRead(), QXbmHandler::canRead(), ICOReader::canRead(), QZipWriter::close(), QTextStreamPrivate::consume(), createReadHandlerHelper(), QAudioOutputPrivate::deviceReady(), QPicture::exec(), QZipReader::fileData(), QAudioOutputPrivate::freeBlocks(), iod_read_fn(), QPdf::ByteStream::operator<<(), QTiffHandler::option(), QtIcoHandler::option(), QPictureIO::pictureFormat(), QPatternist::QIODeviceDelegate::pos(), QBuffer::pos(), QFile::pos(), QHttpPrivate::postMoreData(), QPdf::ByteStream::prepareBuffer(), QMovie::QMovie(), QNonContiguousByteDeviceIoDeviceImpl::QNonContiguousByteDeviceIoDeviceImpl(), qt_term_source(), qtiffSeekProc(), read_dib_body(), QBmpHandler::readHeader(), ICOReader::readHeader(), QMoviePrivate::reset(), QTextStreamPrivate::resetReadBuffer(), QGIFFormat::scan(), seek(), QDataStream::skipRawData(), QFile::symLinkTarget(), and ICOReader::write().
bool QIODevice::putChar | ( | char | c | ) |
Writes the character c to the device.
Returns true on success; otherwise returns false.
Definition at line 1486 of file qiodevice.cpp.
Referenced by QDataStream::operator<<(), and QXmlSerializerPrivate::write().
Reads at most maxSize bytes from the device into data, and returns the number of bytes read.
If an error occurs, such as when attempting to read from a device opened in WriteOnly mode, this function returns -1.
0 is returned when no more data is available for reading. However, reading past the end of the stream is considered an error, so this function returns -1 in those cases (that is, reading on a closed socket or after a process has died).
Definition at line 791 of file qiodevice.cpp.
Referenced by QNetworkReplyImplPrivate::_q_bufferOutgoingData(), QNetworkReplyImplPrivate::_q_copyReadyRead(), QHttpPrivate::_q_slotReadyRead(), QVNCServer::clientCutText(), QSocks5PasswordAuthenticator::continueAuthenticate(), QFile::copy(), QTemporaryFile::createLocalFile(), QUuid::createUuid(), QAudioOutputPrivate::deviceReady(), QTranslatorPrivate::do_load(), QPSPrintEnginePrivate::emitPages(), QXmlInputSource::fetchData(), QZipReader::fileData(), QtMultimediaInternal::QAudioOutputBuffer::fillBuffer(), QTextStreamPrivate::fillReadBuffer(), QAudioOutputPrivate::freeBlocks(), getChar(), QXmlStreamReaderPrivate::getChar_helper(), QHttpNetworkReplyPrivate::getChunkSize(), QTransportAuthPrivate::getClientKey(), ICOReader::iconAt(), iod_read_fn(), QPdf::ByteStream::operator<<(), QDataStream::operator>>(), QSocks5SocketEnginePrivate::parseAuthenticationMethodReply(), QPictureIO::pictureFormat(), QHttpPrivate::postMoreData(), QPdf::ByteStream::prepareBuffer(), qt_fill_input_buffer(), qt_inflateGZipDataFrom(), qt_read_dibv5(), QTgaFile::QTgaFile(), qtiffReadProc(), qws_read_command(), qws_read_uint(), QFtpDTP::read(), read(), QRfbRect::read(), QRfbPixelFormat::read(), QUnixSocket::read(), QRfbServerInit::read(), QRfbSetEncodings::read(), QRfbFrameBufferUpdateRequest::read(), QRfbKeyEvent::read(), QRfbPointerEvent::read(), QRfbClientCutText::read(), ICOReader::read16_24_32BMP(), ICOReader::read1BitBMP(), ICOReader::read4BitBMP(), ICOReader::read8BitBMP(), read_dib_body(), read_pbm_body(), read_pbm_header(), read_xpm_string(), readAll(), readBMPInfoHeader(), QHttpNetworkReplyPrivate::readBodyFast(), QHttpNetworkReplyPrivate::readBodyVeryFast(), QDataStream::readBytes(), QVNCServer::readClient(), ICOReader::readColorTable(), QPatternist::QIODeviceDelegate::readData(), QFile::readData(), QAuthDevice::readData(), QHttpNetworkReplyPrivate::readHeader(), readIconDir(), readIconDirEntry(), readLineData(), QFile::readLineData(), QNetworkAccessFileBackend::readMoreFromFile(), QNonContiguousByteDeviceIoDeviceImpl::readPointer(), QDataStream::readRawData(), QHttpNetworkReplyPrivate::readReplyBodyChunked(), QHttpNetworkReplyPrivate::readReplyBodyRaw(), QHttpNetworkReplyPrivate::readStatus(), QPacketProtocolPrivate::readyToRead(), QDynamicFileResourceRoot::registerSelf(), QFile::rename(), QGIFFormat::scan(), QZipReaderPrivate::scanFiles(), QVNCServer::setEncodings(), QVNCServer::setPixelFormat(), QTransportAuth::setProcessKey(), QDataStream::skipRawData(), QFtpDTP::socketReadyRead(), QSslSocketBackendPrivate::transmit(), ungetChar(), QNetworkDiskCache::updateMetaData(), and QPdfEnginePrivate::writeCompressed().
QByteArray QIODevice::read | ( | qint64 | maxSize | ) |
Reads at most maxSize bytes from the device, and returns the data read as a QByteArray.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This function has no way of reporting errors; returning an empty QByteArray() can mean either that no data was currently available for reading, or that an error occurred.
Definition at line 968 of file qiodevice.cpp.
QByteArray QIODevice::readAll | ( | ) |
Reads all available data from the device, and returns it as a QByteArray.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This function has no way of reporting errors; returning an empty QByteArray() can mean either that no data was currently available for reading, or that an error occurred.
Definition at line 1025 of file qiodevice.cpp.
Referenced by QHttpPrivate::_q_slotReadyRead(), QFontDatabase::addApplicationFont(), QZipWriter::addFile(), QGLShader::compileSourceFile(), QPatternist::ExpressionFactory::createExpression(), QNetworkDiskCache::data(), QDeclarativeXMLHttpRequest::downloadProgress(), QDeclarativeInclude::finished(), QDeclarativeXMLHttpRequest::finished(), QSslCertificate::fromDevice(), QDirectFBPixmapData::fromFile(), QGLPixmapData::fromFile(), QSslCertificate::fromPath(), QFreetypeFace::getFace(), QDeclarativeInclude::include(), QSvgIOHandlerPrivate::load(), QPicture::load(), QDeclarativeDataLoader::load(), QAxScriptManager::load(), QRawFont::loadFromFile(), QTextBrowser::loadResource(), QTextDocument::loadResource(), QDeclarativeDataLoader::networkReplyFinished(), QDeclarativePixmapReader::networkRequestDone(), operator<<(), QDeclarativeDirParser::parse(), QDeclarativeWorkerScriptEnginePrivate::processLoad(), QSslCertificate::QSslCertificate(), QSslKey::QSslKey(), qt_getDefaultFromHomePrinters(), qt_parse_pattern(), QFtpDTP::readAll(), QProcess::readAllStandardError(), QProcess::readAllStandardOutput(), registerFont(), QDeclarativeFontObject::replyFinished(), QPatternist::AccelTreeResourceLoader::retrieveUnparsedText(), QSslSocket::setLocalCertificate(), QSslSocket::setPrivateKey(), QNetworkReplyImplPrivate::setup(), QFtpDTP::socketConnectionClosed(), QFtpDTP::socketReadyRead(), QConfFileSettingsPrivate::syncConfFile(), QSocks5Authenticator::unSeal(), QDeclarativeInclude::worker_include(), and QSvgIconEngine::write().
|
signal |
This signal is emitted when the input (reading) stream is closed in this device.
It is emitted as soon as the closing is detected, which means that there might still be data available for reading with read().
Referenced by QAbstractSocket::disconnectFromHostImplementation(), and QPatternist::QIODeviceDelegate::QIODeviceDelegate().
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an error occurred.
If there are no bytes to be read and there can never be more bytes available (examples include socket closed, pipe closed, sub-process finished), this function returns -1.
This function is called by QIODevice. Reimplement this function when creating a subclass of QIODevice.
When reimplementing this function it is important that this function reads all the required data before returning. This is required in order for QDataStream to be able to operate on the class. QDataStream assumes all the requested information was read and therefore does not retry reading if there was a problem.
Implemented in QtMultimediaInternal::MacInputDevice, MacOutputDevice, QDisabledNetworkReply, QAuthDevice, QProcess, QFile, QAbstractSocket, QSslSocket, QUnixSocket, QByteDeviceWrappingIoDevice, OutputPrivate, InputPrivate, QHttpMultiPartIODevice, InputPrivate, OutputPrivate, QLocalSocket, QBuffer, QPatternist::QIODeviceDelegate, QNetworkReplyImpl, QNetworkReplyFileImpl, QNetworkReplyDataImpl, and QOstDevice.
Referenced by read(), and QUnixSocket::read().
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes, stores the characters in data, and returns the number of bytes read.
If a line could not be read but no error ocurred, this function returns 0. If an error occurs, this function returns the length of what could be read, or -1 if nothing was read.
A terminating '\0' byte is always appended to data, so maxSize must be larger than 1.
Data is read until either of the following conditions are met:
For example, the following code reads a line of characters from a file:
The newline character ('
') is included in the buffer. If a newline is not encountered before maxSize - 1 bytes are read, a newline will not be inserted into the buffer. On windows newline characters are replaced with '
'.
This function calls readLineData(), which is implemented using repeated calls to getChar(). You can provide a more efficient implementation by reimplementing readLineData() in your own subclass.
Definition at line 1110 of file qiodevice.cpp.
Referenced by QHttpPrivate::_q_slotReadyRead(), QBenchmarkValgrindUtils::extractResult(), QTextStreamPrivate::fillReadBuffer(), fontFile(), fontPath(), QHostInfo::localDomainName(), QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(), qt_getLprPrinters(), qt_parseEtcLpPrinters(), qt_parseNsswitchConf(), qt_parsePrintcap(), qt_parsePrintersConf(), qt_read_xpm_image_or_array(), read_pbm_int(), read_xbm_body(), read_xbm_header(), readLine(), QFtpPI::readyRead(), QFtpDTP::socketReadyRead(), and QCoreApplicationData::~QCoreApplicationData().
QByteArray QIODevice::readLine | ( | qint64 | maxSize = 0 | ) |
Reads a line from the device, but no more than maxSize characters, and returns the result as a QByteArray.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This function has no way of reporting errors; returning an empty QByteArray() can mean either that no data was currently available for reading, or that an error occurred.
Definition at line 1220 of file qiodevice.cpp.
Reads up to maxSize characters into data and returns the number of characters read.
This function is called by readLine(), and provides its base implementation, using getChar(). Buffered devices can improve the performance of readLine() by reimplementing this function.
readLine() appends a '\0' byte to data; readLineData() does not need to do this.
If you reimplement this function, be careful to return the correct value: it should return the number of bytes read in this line, including the terminating newline, or 0 if there is no line to be read at this point. If an error occurs, it should return -1 if and only if no bytes were read. Reading past EOF is considered an error.
Reimplemented in QFile, and QAbstractSocket.
Definition at line 1285 of file qiodevice.cpp.
Referenced by readLine(), QAbstractSocket::readLineData(), and QFile::readLineData().
|
signal |
This signal is emitted once every time new data is available for reading from the device.
It will only be emitted again once new data is available, such as when a new payload of network data has arrived on your network socket, or when a new block of data has been appended to your device.
readyRead() is not emitted recursively; if you reenter the event loop or call waitForReadyRead() inside a slot connected to the readyRead() signal, the signal will not be reemitted (although waitForReadyRead() may still return true).
Note for developers implementing classes derived from QIODevice: you should always emit readyRead() when new data has arrived (do not emit it only because there's data still to be read in your buffers). Do not emit readyRead() in other conditions.
Referenced by QAuthDevice::authorizeMessage(), QAuthDevice::QAuthDevice(), QByteDeviceWrappingIoDevice::QByteDeviceWrappingIoDevice(), QPatternist::QIODeviceDelegate::QIODeviceDelegate(), and QUnixSocketPrivate::readActivated().
|
virtual |
Seeks to the start of input for random-access devices.
Returns true on success; otherwise returns false (for example, if the device is not open).
Note that when using a QTextStream on a QFile, calling reset() on the QFile will not have the expected result because QTextStream buffers the file. Use the QTextStream::seek() function instead.
Reimplemented in QByteDeviceWrappingIoDevice, QHttpMultiPartIODevice, and QPatternist::QIODeviceDelegate.
Definition at line 732 of file qiodevice.cpp.
Referenced by QMacPasteboardMimeVCard::convertFromMime(), QPdf::ByteStream::operator<<(), QPdf::ByteStream::prepareBuffer(), QPatternist::QIODeviceDelegate::reset(), QNonContiguousByteDeviceIoDeviceImpl::reset(), and QPdf::ByteStream::stream().
|
virtual |
For random-access devices, this function sets the current position to pos, returning true on success, or false if an error occurred.
For sequential devices, the default behavior is to do nothing and return false.
When subclassing QIODevice, you must call QIODevice::seek() at the start of your function to ensure integrity with QIODevice's built-in buffer. The base implementation always returns true.
Reimplemented in QAuthDevice, QFile, QBuffer, and QPatternist::QIODeviceDelegate.
Definition at line 659 of file qiodevice.cpp.
Referenced by QHttpPrivate::_q_slotConnected(), QZipWriterPrivate::addEntry(), QTiffHandler::canRead(), QXbmHandler::canRead(), ICOReader::canRead(), QZipWriter::close(), createReadHandlerHelper(), QAudioOutputPrivate::deviceReady(), QPicture::exec(), QZipReader::fileData(), QAudioOutputPrivate::freeBlocks(), ICOReader::iconAt(), iod_read_fn(), QPdf::ByteStream::operator<<(), QTiffHandler::option(), QtIcoHandler::option(), QPictureIO::pictureFormat(), QPicture::play(), QPdf::ByteStream::prepareBuffer(), qt_fill_input_buffer(), qt_term_source(), QTgaFile::QTgaFile(), qtiffSeekProc(), read(), read_dib_body(), ICOReader::readBMPHeader(), ICOReader::readIconEntry(), QTgaFile::readImage(), readLine(), reset(), QNonContiguousByteDeviceIoDeviceImpl::reset(), QGIFFormat::scan(), QZipReaderPrivate::scanFiles(), QPatternist::QIODeviceDelegate::seek(), QBuffer::seek(), QFile::seek(), QDataStream::skipRawData(), QFile::symLinkTarget(), and write().
|
protected |
Sets the human readable description of the last device error that occurred to str.
Definition at line 1660 of file qiodevice.cpp.
Referenced by QUdpSocket::bind(), QAbstractSocket::connectToHostImplementation(), QPatternist::QIODeviceDelegate::networkTimeout(), QOstDevice::open(), QAbstractSocket::readData(), QUdpSocket::readDatagram(), QNetworkReply::setError(), QAbstractSocket::setSocketDescriptor(), QProcess::start(), QAbstractSocket::waitForBytesWritten(), QAbstractSocket::waitForConnected(), QAbstractSocket::waitForDisconnected(), QAbstractSocket::waitForReadyRead(), QOstDevice::writeData(), QAbstractSocket::writeData(), QProcess::writeData(), and QUdpSocket::writeDatagram().
|
protected |
Sets the OpenMode of the device to openMode.
Call this function to set the open mode if the flags change after the device has been opened.
Definition at line 477 of file qiodevice.cpp.
Referenced by QUnixSocket::abort(), QUnixSocket::connect(), QPatternist::QIODeviceDelegate::open(), QTemporaryFile::open(), QPatternist::QIODeviceDelegate::QIODeviceDelegate(), QUnixSocket::QUnixSocket(), and QUnixSocket::setSocketDescriptor().
void QIODevice::setTextModeEnabled | ( | bool | enabled | ) |
If enabled is true, this function sets the Text flag on the device; otherwise the Text flag is removed.
This feature is useful for classes that provide custom end-of-line handling on a QIODevice.
The IO device should be opened before calling this function.
Definition at line 499 of file qiodevice.cpp.
Referenced by QTextStreamPrivate::fillReadBuffer(), and QTextStreamPrivate::flushWriteBuffer().
|
virtual |
For open random-access devices, this function returns the size of the device.
For open sequential devices, bytesAvailable() is returned.
If the device is closed, the size returned will not reflect the actual size of the device.
Reimplemented in QByteDeviceWrappingIoDevice, QFile, QHttpMultiPartIODevice, QBuffer, QPatternist::QIODeviceDelegate, QNetworkReplyFileImpl, and QNetworkReplyDataImpl.
Definition at line 642 of file qiodevice.cpp.
Referenced by QHttpPrivate::_q_slotConnected(), QFtpPrivate::_q_startNextCommand(), atEnd(), bytesAvailable(), QProcess::bytesToWrite(), QNetworkAccessManager::createRequest(), QPSPrintEnginePrivate::flushPage(), iod_read_fn(), QDeclarativeDataLoader::load(), open(), QHttpPrivate::postMoreData(), QPdf::ByteStream::prepareBuffer(), QFtp::put(), QTgaFile::QTgaFile(), qtiffSeekProc(), readAll(), QUnixSocket::readData(), readLine(), QZipReaderPrivate::scanFiles(), QNetworkAccessHttpBackend::sendCacheContents(), QNetworkReply::setReadBufferSize(), QAbstractSocket::setReadBufferSize(), QUnixSocket::setReadBufferSize(), QUnixSocket::setRightsBufferSize(), QPatternist::QIODeviceDelegate::size(), QNonContiguousByteDeviceIoDeviceImpl::size(), QDataStream::skipRawData(), QFile::symLinkTarget(), and QAbstractSocket::writeData().
void QIODevice::ungetChar | ( | char | c | ) |
Puts the character c back into the device, and decrements the current position unless the position is 0.
This function is usually called to "undo" a getChar() operation, such as when writing a backtracking parser.
If c was not previously read from the device, the behavior is undefined.
Definition at line 1462 of file qiodevice.cpp.
Referenced by ICOReader::canRead(), QSocks5SocketEnginePrivate::parseRequestMethodReply(), qt_read_xpm_image_or_array(), and read_xpm_body().
|
virtual |
For buffered devices, this function waits until a payload of buffered written data has been written to the device and the bytesWritten() signal has been emitted, or until msecs milliseconds have passed.
If msecs is -1, this function will not time out. For unbuffered devices, it returns immediately.
Returns true if a payload of data was written to the device; otherwise returns false (i.e. if the operation timed out, or if an error occurred).
This function can operate without an event loop. It is useful when writing non-GUI applications and when performing I/O operations in a non-GUI thread.
If called from within a slot connected to the bytesWritten() signal, bytesWritten() will not be reemitted.
Reimplement this function to provide a blocking API for a custom device. The default implementation does nothing, and returns false.
Reimplemented in QUnixSocket, QAbstractSocket, QProcess, QSslSocket, QLocalSocket, and QPatternist::QIODeviceDelegate.
Definition at line 1648 of file qiodevice.cpp.
Referenced by QUnixSocket::read(), and QPatternist::QIODeviceDelegate::waitForBytesWritten().
|
virtual |
Blocks until new data is available for reading and the readyRead() signal has been emitted, or until msecs milliseconds have passed.
If msecs is -1, this function will not time out.
Returns true if new data is available for reading; otherwise returns false (if the operation timed out or if an error occurred).
This function can operate without an event loop. It is useful when writing non-GUI applications and when performing I/O operations in a non-GUI thread.
If called from within a slot connected to the readyRead() signal, readyRead() will not be reemitted.
Reimplement this function to provide a blocking API for a custom device. The default implementation does nothing, and returns false.
Reimplemented in QUnixSocket, QAbstractSocket, QProcess, QSslSocket, QLocalSocket, QPatternist::QIODeviceDelegate, and QOstDevice.
Definition at line 1616 of file qiodevice.cpp.
Referenced by QXmlInputSource::fetchData(), QUnixSocket::read(), QPacketProtocol::waitForReadyRead(), and QPatternist::QIODeviceDelegate::waitForReadyRead().
Writes at most maxSize bytes of data from data to the device.
Returns the number of bytes that were actually written, or -1 if an error occurred.
Definition at line 1342 of file qiodevice.cpp.
Referenced by QHttpPrivate::_q_slotConnected(), QHttpPrivate::_q_slotReadyRead(), QFtpPI::abort(), QZipWriterPrivate::addEntry(), QNetworkReplyImplPrivate::appendDownstreamData(), QNetworkReplyImplPrivate::appendDownstreamDataDownloadBuffer(), QSocks5PasswordAuthenticator::beginAuthenticate(), buttonChange(), QVNCCursor::clearClientCursor(), QZipWriter::close(), QTemporaryFile::createLocalFile(), QGraphicsAnchorLayoutPrivate::dumpGraph(), dumpOutput(), QPdfEnginePrivate::embedFont(), QPSPrintEnginePrivate::emitHeader(), QPSPrintEnginePrivate::emitPages(), QtopiaPrintEngine::end(), QZipReader::extractAll(), QTextStreamPrivate::flushWriteBuffer(), QAudioInputPrivate::freeBlocks(), QTestLiteStaticInfoPrivate::initializeSupportedAtoms(), QVNCServer::newConnection(), QPdf::ByteStream::operator<<(), QDataStream::operator<<(), QPatternist::XsdStateMachine< XsdSchemaToken::NodeName >::outputGraph(), QHttpNetworkConnectionChannel::pipelineFlush(), QHttpPrivate::postMoreData(), QPdf::ByteStream::prepareBuffer(), qpiw_write_fn(), qt_empty_output_buffer(), qt_get_net_supported(), qt_get_net_virtual_roots(), qt_term_destination(), qt_write_dib(), qt_write_dibv5(), QVNCDirtyMap::QVNCDirtyMap(), qws_write_command(), qws_write_uint(), QAudioInputPrivate::read(), QUnixSocket::read(), QVNCServer::readClient(), registerFont(), QFile::rename(), QPicture::save(), QBuffer::seek(), QPacketProtocol::send(), QWaylandSelection::send(), QVNCCursor::sendClientCursor(), QHttpNetworkConnectionChannel::sendRequest(), QSocks5SocketEnginePrivate::sendRequestMethod(), QSslSocketBackendPrivate::startHandshake(), QFtpPI::startNextCmd(), QSslSocketBackendPrivate::transmit(), QNetworkDiskCache::updateMetaData(), QNetworkAccessFileBackend::uploadReadyReadSlot(), QPatternist::ColorOutputPrivate::write(), QVNCClientCursor::write(), ICOReader::write(), write(), QRfbRect::write(), QRfbPixelFormat::write(), QUnixSocket::write(), QRfbServerInit::write(), QRfbRawEncoder::write(), QRfbSingleColorHextile< SRC >::write(), QRfbDualColorHextile< SRC >::write(), QRfbMultiColorHextile< SRC >::write(), QRfbHextileEncoder< SRC >::write(), QXmlStreamWriterPrivate::write(), write_pbm_image(), write_xbm_image(), writeBMPInfoHeader(), QFtpDTP::writeData(), QAuthDevice::writeData(), writeIconDir(), writeIconDirEntry(), QConfFileSettingsPrivate::writeIniFile(), and QDataStream::writeRawData().
qint64 QIODevice::write | ( | const char * | data | ) |
Writes data from a zero-terminated string of 8-bit characters to the device.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns the number of bytes that were actually written, or -1 if an error occurred. This is equivalent to
Definition at line 1435 of file qiodevice.cpp.
|
inline |
Writes the content of byteArray to the device.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns the number of bytes that were actually written, or -1 if an error occurred.
Definition at line 126 of file qiodevice.h.
Writes up to maxSize bytes from data to the device.
Returns the number of bytes written, or -1 if an error occurred.
This function is called by QIODevice. Reimplement this function when creating a subclass of QIODevice.
When reimplementing this function it is important that this function writes all the data available before returning. This is required in order for QDataStream to be able to operate on the class. QDataStream assumes all the information was written and therefore does not retry writing if there was a problem.
Implemented in QtMultimediaInternal::MacInputDevice, MacOutputDevice, QAuthDevice, QProcess, QFile, QAbstractSocket, QSslSocket, QUnixSocket, QByteDeviceWrappingIoDevice, QNetworkReply, OutputPrivate, InputPrivate, QHttpMultiPartIODevice, InputPrivate, OutputPrivate, QLocalSocket, QBuffer, and QOstDevice.
Referenced by QUnixSocket::read(), and write().