You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
554 lines
28 KiB
554 lines
28 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/tools/tqiodevice.cpp:40 -->
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>TQIODevice Class</title>
|
|
<style type="text/css"><!--
|
|
fn { margin-left: 1cm; text-indent: -1cm; }
|
|
a:link { color: #004faf; text-decoration: none }
|
|
a:visited { color: #672967; text-decoration: none }
|
|
body { background: #ffffff; color: black; }
|
|
--></style>
|
|
</head>
|
|
<body>
|
|
|
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
|
<tr bgcolor="#E5E5E5">
|
|
<td valign=center>
|
|
<a href="index.html">
|
|
<font color="#004faf">Home</font></a>
|
|
| <a href="classes.html">
|
|
<font color="#004faf">All Classes</font></a>
|
|
| <a href="mainclasses.html">
|
|
<font color="#004faf">Main Classes</font></a>
|
|
| <a href="annotated.html">
|
|
<font color="#004faf">Annotated</font></a>
|
|
| <a href="groups.html">
|
|
<font color="#004faf">Grouped Classes</font></a>
|
|
| <a href="functions.html">
|
|
<font color="#004faf">Functions</font></a>
|
|
</td>
|
|
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQIODevice Class Reference</h1>
|
|
|
|
<p>The TQIODevice class is the base class of I/O devices.
|
|
<a href="#details">More...</a>
|
|
<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when TQt is built with thread support.</p>
|
|
<p><tt>#include <<a href="tqiodevice-h.html">tqiodevice.h</a>></tt>
|
|
<p>Inherited by <a href="tqbuffer.html">TQBuffer</a>, <a href="tqfile.html">TQFile</a>, <a href="tqsocket.html">TQSocket</a>, and <a href="tqsocketdevice.html">TQSocketDevice</a>.
|
|
<p><a href="tqiodevice-members.html">List of all member functions.</a>
|
|
<h2>Public Members</h2>
|
|
<ul>
|
|
<li class=fn>typedef TQ_ULONG <a href="#Offset"><b>Offset</b></a></li>
|
|
<li class=fn><a href="#TQIODevice"><b>TQIODevice</b></a> ()</li>
|
|
<li class=fn>virtual <a href="#~TQIODevice"><b>~TQIODevice</b></a> ()</li>
|
|
<li class=fn>int <a href="#flags"><b>flags</b></a> () const</li>
|
|
<li class=fn>int <a href="#mode"><b>mode</b></a> () const</li>
|
|
<li class=fn>int <a href="#state"><b>state</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isDirectAccess"><b>isDirectAccess</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isSequentialAccess"><b>isSequentialAccess</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isCombinedAccess"><b>isCombinedAccess</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isBuffered"><b>isBuffered</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isRaw"><b>isRaw</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isSynchronous"><b>isSynchronous</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isAsynchronous"><b>isAsynchronous</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isTranslated"><b>isTranslated</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isReadable"><b>isReadable</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isWritable"><b>isWritable</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isReadWrite"><b>isReadWrite</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isInactive"><b>isInactive</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isOpen"><b>isOpen</b></a> () const</li>
|
|
<li class=fn>int <a href="#status"><b>status</b></a> () const</li>
|
|
<li class=fn>void <a href="#resetStatus"><b>resetStatus</b></a> ()</li>
|
|
<li class=fn>virtual bool <a href="#open"><b>open</b></a> ( int mode ) = 0</li>
|
|
<li class=fn>virtual void <a href="#close"><b>close</b></a> () = 0</li>
|
|
<li class=fn>virtual void <a href="#flush"><b>flush</b></a> () = 0</li>
|
|
<li class=fn>virtual Offset <a href="#size"><b>size</b></a> () const = 0</li>
|
|
<li class=fn>virtual Offset <a href="#at"><b>at</b></a> () const</li>
|
|
<li class=fn>virtual bool <a href="#at-2"><b>at</b></a> ( Offset pos )</li>
|
|
<li class=fn>virtual bool <a href="#atEnd"><b>atEnd</b></a> () const</li>
|
|
<li class=fn>bool <a href="#reset"><b>reset</b></a> ()</li>
|
|
<li class=fn>virtual TQ_LONG <a href="#readBlock"><b>readBlock</b></a> ( char * data, TQ_ULONG maxlen ) = 0</li>
|
|
<li class=fn>virtual TQ_LONG <a href="#writeBlock"><b>writeBlock</b></a> ( const char * data, TQ_ULONG len ) = 0</li>
|
|
<li class=fn>virtual TQ_LONG <a href="#readLine"><b>readLine</b></a> ( char * data, TQ_ULONG maxlen )</li>
|
|
<li class=fn>TQ_LONG <a href="#writeBlock-2"><b>writeBlock</b></a> ( const TQByteArray & data )</li>
|
|
<li class=fn>virtual TQByteArray <a href="#readAll"><b>readAll</b></a> ()</li>
|
|
<li class=fn>virtual int <a href="#getch"><b>getch</b></a> () = 0</li>
|
|
<li class=fn>virtual int <a href="#putch"><b>putch</b></a> ( int ch ) = 0</li>
|
|
<li class=fn>virtual int <a href="#ungetch"><b>ungetch</b></a> ( int ch ) = 0</li>
|
|
</ul>
|
|
<h2>Protected Members</h2>
|
|
<ul>
|
|
<li class=fn>void <a href="#setFlags"><b>setFlags</b></a> ( int flags )</li>
|
|
<li class=fn>void <a href="#setType"><b>setType</b></a> ( int type )</li>
|
|
<li class=fn>void <a href="#setMode"><b>setMode</b></a> ( int mode )</li>
|
|
<li class=fn>void <a href="#setState"><b>setState</b></a> ( int state )</li>
|
|
<li class=fn>void <a href="#setStatus"><b>setStatus</b></a> ( int s )</li>
|
|
</ul>
|
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
|
|
|
|
|
|
|
<p> The TQIODevice class is the base class of I/O devices.
|
|
<p>
|
|
<p> An I/O device represents a medium that one can read bytes from
|
|
and/or write bytes to. The TQIODevice class is the abstract
|
|
superclass of all such devices; classes such as <a href="tqfile.html">TQFile</a>, <a href="tqbuffer.html">TQBuffer</a> and
|
|
<a href="tqsocket.html">TQSocket</a> inherit TQIODevice and implement virtual functions such as
|
|
write() appropriately.
|
|
<p> Although applications sometimes use TQIODevice directly, it is
|
|
usually better to use <a href="tqtextstream.html">TQTextStream</a> and <a href="tqdatastream.html">TQDataStream</a>, which provide
|
|
stream operations on any TQIODevice subclass. TQTextStream provides
|
|
text-oriented stream functionality (for human-readable ASCII
|
|
files, for example), whereas TQDataStream deals with binary data in
|
|
a totally platform-independent manner.
|
|
<p> The public member functions in TQIODevice roughly fall into two
|
|
groups: the action functions and the state access functions. The
|
|
most important action functions are:
|
|
<p> <ul>
|
|
<p> <li> <a href="#open">open</a>() opens a device for reading and/or writing, depending on
|
|
the mode argument.
|
|
<p> <li> <a href="#close">close</a>() closes the device and tidies up (e.g. flushes buffered
|
|
data)
|
|
<p> <li> <a href="#readBlock">readBlock</a>() reads a block of data from the device.
|
|
<p> <li> <a href="#writeBlock">writeBlock</a>() writes a block of data to the device.
|
|
<p> <li> <a href="#readLine">readLine</a>() reads a line (of text, usually) from the device.
|
|
<p> <li> <a href="#flush">flush</a>() ensures that all buffered data are written to the real device.
|
|
<p> </ul>
|
|
<p> There are also some other, less used, action functions:
|
|
<p> <ul>
|
|
<p> <li> <a href="#getch">getch</a>() reads a single character.
|
|
<p> <li> <a href="#ungetch">ungetch</a>() forgets the last call to getch(), if possible.
|
|
<p> <li> <a href="#putch">putch</a>() writes a single character.
|
|
<p> <li> <a href="#size">size</a>() returns the size of the device, if there is one.
|
|
<p> <li> <a href="#at">at</a>() returns the current read/write pointer's position, if there
|
|
is one for this device, or it moves the pointer if given an offset.
|
|
<p> <li> <a href="#atEnd">atEnd</a>() indicates whether there is more to read, if this is
|
|
meaningful for this device.
|
|
<p> <li> <a href="#reset">reset</a>() moves the read/write pointer to the start of the
|
|
device, if that is possible for this device.
|
|
<p> </ul>
|
|
<p> The state access are all "get" functions. The TQIODevice subclass
|
|
calls <a href="#setState">setState</a>() to update the state, and simple access functions
|
|
tell the user of the device what the device's state is. Here are
|
|
the settings, and their associated access functions:
|
|
<p> <ul>
|
|
<p> <li> Access type. Some devices are direct access (it is possible
|
|
to read/write anywhere), whereas others are sequential. TQIODevice
|
|
provides the access functions (<a href="#isDirectAccess">isDirectAccess</a>(),
|
|
<a href="#isSequentialAccess">isSequentialAccess</a>(), and <a href="#isCombinedAccess">isCombinedAccess</a>()) to tell users what a
|
|
given I/O device supports.
|
|
<p> <li> Buffering. Some devices are accessed in raw mode, whereas
|
|
others are buffered. Buffering usually provides greater
|
|
efficiency, particularly for small read/write operations.
|
|
<a href="#isBuffered">isBuffered</a>() tells the user whether a given device is buffered.
|
|
(This can often be set by the application in the call to <a href="#open">open</a>().)
|
|
<p> <li> Synchronicity. Synchronous devices work immediately (for
|
|
example, files). When you read from a file, the file delivers its
|
|
data straight away. Other kinds of device, such as a socket
|
|
connected to a HTTP server, may not deliver the data until seconds
|
|
after you ask to read it. <a href="#isSynchronous">isSynchronous</a>() and <a href="#isAsynchronous">isAsynchronous</a>()
|
|
tell the user how this device operates.
|
|
<p> <li> CR/LF translation. For simplicity, applications often like to
|
|
see just a single CR/LF style, and TQIODevice subclasses can
|
|
provide this. <a href="#isTranslated">isTranslated</a>() returns TRUE if this object
|
|
translates CR/LF to just LF. (This can often be set by the
|
|
application in the call to open().)
|
|
<p> <li> Permissions. Some files cannot be written. For example,
|
|
<a href="#isReadable">isReadable</a>(), <a href="#isWritable">isWritable</a>() and <a href="#isReadWrite">isReadWrite</a>() tell the application
|
|
whether it can read from and write to a given device. (This can
|
|
often be set by the application in the call to <a href="#open">open</a>().)
|
|
<p> <li> Finally, <a href="#isOpen">isOpen</a>() returns TRUE if the device is open, i.e.
|
|
after an open() call.
|
|
<p> </ul>
|
|
<p> TQIODevice provides numerous pure virtual functions that you need
|
|
to implement when subclassing it. Here is a skeleton subclass with
|
|
all the members you are sure to need and some that you will
|
|
probably need:
|
|
<p> <pre>
|
|
class MyDevice : public TQIODevice
|
|
{
|
|
public:
|
|
MyDevice();
|
|
~MyDevice();
|
|
|
|
bool open( int mode );
|
|
void close();
|
|
void flush();
|
|
|
|
uint size() const;
|
|
int at() const; // non-pure virtual
|
|
bool at( int ); // non-pure virtual
|
|
bool atEnd() const; // non-pure virtual
|
|
|
|
int readBlock( char *data, uint maxlen );
|
|
int writeBlock( const char *data, uint len );
|
|
int readLine( char *data, uint maxlen );
|
|
|
|
int getch();
|
|
int putch( int );
|
|
int ungetch( int );
|
|
};
|
|
</pre>
|
|
|
|
<p> The three non-pure virtual functions need not be reimplemented for
|
|
sequential devices.
|
|
<p> <p>See also <a href="tqdatastream.html">TQDataStream</a>, <a href="tqtextstream.html">TQTextStream</a>, and <a href="io.html">Input/Output and Networking</a>.
|
|
|
|
<hr><h2>Member Type Documentation</h2>
|
|
<h3 class=fn><a name="Offset"></a>TQIODevice::Offset</h3>
|
|
|
|
<p> The offset within the device.
|
|
|
|
<hr><h2>Member Function Documentation</h2>
|
|
<h3 class=fn><a name="TQIODevice"></a>TQIODevice::TQIODevice ()
|
|
</h3>
|
|
Constructs an I/O device.
|
|
|
|
<h3 class=fn><a name="~TQIODevice"></a>TQIODevice::~TQIODevice ()<tt> [virtual]</tt>
|
|
</h3>
|
|
Destroys the I/O device.
|
|
|
|
<h3 class=fn><a href="tqiodevice.html#Offset">Offset</a> <a name="at"></a>TQIODevice::at () const<tt> [virtual]</tt>
|
|
</h3>
|
|
Virtual function that returns the current I/O device position.
|
|
<p> This is the position of the data read/write head of the I/O
|
|
device.
|
|
<p> <p>See also <a href="#size">size</a>().
|
|
|
|
<p>Example: <a href="distributor-example.html#x2666">distributor/distributor.ui.h</a>.
|
|
<p>Reimplemented in <a href="tqsocket.html#at">TQSocket</a>.
|
|
<h3 class=fn>bool <a name="at-2"></a>TQIODevice::at ( <a href="tqiodevice.html#Offset">Offset</a> pos )<tt> [virtual]</tt>
|
|
</h3>
|
|
Virtual function that sets the I/O device position to <em>pos</em>.
|
|
Returns TRUE if the position was successfully set, i.e. <em>pos</em> is
|
|
within range and the seek was successful; otherwise returns FALSE.
|
|
<p> <p>See also <a href="#size">size</a>().
|
|
|
|
<p>Reimplemented in <a href="tqsocket.html#at-2">TQSocket</a>.
|
|
<h3 class=fn>bool <a name="atEnd"></a>TQIODevice::atEnd () const<tt> [virtual]</tt>
|
|
</h3>
|
|
Virtual function that returns TRUE if the I/O device position is
|
|
at the end of the input; otherwise returns FALSE.
|
|
|
|
<p>Reimplemented in <a href="tqfile.html#atEnd">TQFile</a> and <a href="tqsocket.html#atEnd">TQSocket</a>.
|
|
<h3 class=fn>void <a name="close"></a>TQIODevice::close ()<tt> [pure virtual]</tt>
|
|
</h3>
|
|
|
|
<p> Closes the I/O device.
|
|
<p> This virtual function must be reimplemented by all subclasses.
|
|
<p> <p>See also <a href="#open">open</a>().
|
|
|
|
<p>Example: <a href="grapher-nsplugin-example.html#x2742">grapher/grapher.cpp</a>.
|
|
<p>Reimplemented in <a href="tqfile.html#close">TQFile</a> and <a href="tqsocket.html#close">TQSocket</a>.
|
|
<h3 class=fn>int <a name="flags"></a>TQIODevice::flags () const
|
|
</h3>
|
|
|
|
<p> Returns the current I/O device flags setting.
|
|
<p> Flags consists of mode flags and state flags.
|
|
<p> <p>See also <a href="#mode">mode</a>() and <a href="#state">state</a>().
|
|
|
|
<h3 class=fn>void <a name="flush"></a>TQIODevice::flush ()<tt> [pure virtual]</tt>
|
|
</h3>
|
|
|
|
<p> Flushes an open I/O device.
|
|
<p> This virtual function must be reimplemented by all subclasses.
|
|
|
|
<p>Reimplemented in <a href="tqfile.html#flush">TQFile</a> and <a href="tqsocket.html#flush">TQSocket</a>.
|
|
<h3 class=fn>int <a name="getch"></a>TQIODevice::getch ()<tt> [pure virtual]</tt>
|
|
</h3>
|
|
|
|
<p> Reads a single byte/character from the I/O device.
|
|
<p> Returns the byte/character read, or -1 if the end of the I/O
|
|
device has been reached.
|
|
<p> This virtual function must be reimplemented by all subclasses.
|
|
<p> <p>See also <a href="#putch">putch</a>() and <a href="#ungetch">ungetch</a>().
|
|
|
|
<p>Reimplemented in <a href="tqfile.html#getch">TQFile</a> and <a href="tqsocket.html#getch">TQSocket</a>.
|
|
<h3 class=fn>bool <a name="isAsynchronous"></a>TQIODevice::isAsynchronous () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the device is an asynchronous device; otherwise
|
|
returns FALSE, i.e. if the device is a synchronous device.
|
|
<p> This mode is currently not in use.
|
|
<p> <p>See also <a href="#isSynchronous">isSynchronous</a>().
|
|
|
|
<h3 class=fn>bool <a name="isBuffered"></a>TQIODevice::isBuffered () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the I/O device is a buffered device; otherwise
|
|
returns FALSE, i.e. the device is a raw device.
|
|
<p> <p>See also <a href="#isRaw">isRaw</a>().
|
|
|
|
<h3 class=fn>bool <a name="isCombinedAccess"></a>TQIODevice::isCombinedAccess () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the I/O device is a combined access (both direct
|
|
and sequential) device; otherwise returns FALSE.
|
|
<p> This access method is currently not in use.
|
|
|
|
<h3 class=fn>bool <a name="isDirectAccess"></a>TQIODevice::isDirectAccess () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the I/O device is a direct access device;
|
|
otherwise returns FALSE, i.e. if the device is a sequential access
|
|
device.
|
|
<p> <p>See also <a href="#isSequentialAccess">isSequentialAccess</a>().
|
|
|
|
<h3 class=fn>bool <a name="isInactive"></a>TQIODevice::isInactive () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the I/O device state is 0, i.e. the device is not
|
|
open; otherwise returns FALSE.
|
|
<p> <p>See also <a href="#isOpen">isOpen</a>().
|
|
|
|
<h3 class=fn>bool <a name="isOpen"></a>TQIODevice::isOpen () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the I/O device has been opened; otherwise returns
|
|
FALSE.
|
|
<p> <p>See also <a href="#isInactive">isInactive</a>().
|
|
|
|
<p>Example: <a href="networkprotocol-example.html#x670">network/networkprotocol/nntp.cpp</a>.
|
|
<h3 class=fn>bool <a name="isRaw"></a>TQIODevice::isRaw () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the device is a raw device; otherwise returns
|
|
FALSE, i.e. if the device is a buffered device.
|
|
<p> <p>See also <a href="#isBuffered">isBuffered</a>().
|
|
|
|
<h3 class=fn>bool <a name="isReadWrite"></a>TQIODevice::isReadWrite () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the I/O device was opened using <a href="tqfile.html#open">IO_ReadWrite</a>
|
|
mode; otherwise returns FALSE.
|
|
<p> <p>See also <a href="#isReadable">isReadable</a>() and <a href="#isWritable">isWritable</a>().
|
|
|
|
<h3 class=fn>bool <a name="isReadable"></a>TQIODevice::isReadable () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the I/O device was opened using <a href="tqfile.html#open">IO_ReadOnly</a> or
|
|
<a href="tqfile.html#open">IO_ReadWrite</a> mode; otherwise returns FALSE.
|
|
<p> <p>See also <a href="#isWritable">isWritable</a>() and <a href="#isReadWrite">isReadWrite</a>().
|
|
|
|
<h3 class=fn>bool <a name="isSequentialAccess"></a>TQIODevice::isSequentialAccess () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the device is a sequential access device;
|
|
otherwise returns FALSE, i.e. if the device is a direct access
|
|
device.
|
|
<p> Operations involving <a href="#size">size</a>() and <a href="#at">at</a>(int) are not valid on
|
|
sequential devices.
|
|
<p> <p>See also <a href="#isDirectAccess">isDirectAccess</a>().
|
|
|
|
<h3 class=fn>bool <a name="isSynchronous"></a>TQIODevice::isSynchronous () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the I/O device is a synchronous device; otherwise
|
|
returns FALSE, i.e. the device is an asynchronous device.
|
|
<p> <p>See also <a href="#isAsynchronous">isAsynchronous</a>().
|
|
|
|
<h3 class=fn>bool <a name="isTranslated"></a>TQIODevice::isTranslated () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the I/O device translates carriage-return and
|
|
linefeed characters; otherwise returns FALSE.
|
|
<p> A <a href="tqfile.html">TQFile</a> is translated if it is opened with the <a href="tqfile.html#open">IO_Translate</a>
|
|
mode flag.
|
|
|
|
<h3 class=fn>bool <a name="isWritable"></a>TQIODevice::isWritable () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the I/O device was opened using <a href="tqfile.html#open">IO_WriteOnly</a> or
|
|
<a href="tqfile.html#open">IO_ReadWrite</a> mode; otherwise returns FALSE.
|
|
<p> <p>See also <a href="#isReadable">isReadable</a>() and <a href="#isReadWrite">isReadWrite</a>().
|
|
|
|
<h3 class=fn>int <a name="mode"></a>TQIODevice::mode () const
|
|
</h3>
|
|
|
|
<p> Returns bits OR'ed together that specify the current operation
|
|
mode.
|
|
<p> These are the flags that were given to the <a href="#open">open</a>() function.
|
|
<p> The flags are <a href="tqfile.html#open">IO_ReadOnly</a>, <a href="tqfile.html#open">IO_WriteOnly</a>, <a href="tqfile.html#open">IO_ReadWrite</a>,
|
|
<a href="tqfile.html#open">IO_Append</a>, <a href="tqfile.html#open">IO_Truncate</a> and <a href="tqfile.html#open">IO_Translate</a>.
|
|
|
|
<h3 class=fn>bool <a name="open"></a>TQIODevice::open ( int mode )<tt> [pure virtual]</tt>
|
|
</h3>
|
|
|
|
<p> Opens the I/O device using the specified <em>mode</em>. Returns TRUE if
|
|
the device was successfully opened; otherwise returns FALSE.
|
|
<p> The mode parameter <em>mode</em> must be an OR'ed combination of the
|
|
following flags.
|
|
<center><table cellpadding="4" cellspacing="2" border="0">
|
|
<tr bgcolor="#a2c511"> <th valign="top">Mode flags <th valign="top">Meaning
|
|
<tr bgcolor="#f0f0f0"> <td valign="top"><a href="tqfile.html#open">IO_Raw</a> <td valign="top">specifies raw (unbuffered) file access.
|
|
<tr bgcolor="#d0d0d0"> <td valign="top"><a href="tqfile.html#open">IO_ReadOnly</a> <td valign="top">opens a file in read-only mode.
|
|
<tr bgcolor="#f0f0f0"> <td valign="top"><a href="tqfile.html#open">IO_WriteOnly</a> <td valign="top">opens a file in write-only mode.
|
|
<tr bgcolor="#d0d0d0"> <td valign="top"><a href="tqfile.html#open">IO_ReadWrite</a> <td valign="top">opens a file in read/write mode.
|
|
<tr bgcolor="#f0f0f0"> <td valign="top"><a href="tqfile.html#open">IO_Append</a> <td valign="top">sets the file index to the end of the file.
|
|
<tr bgcolor="#d0d0d0"> <td valign="top"><a href="tqfile.html#open">IO_Truncate</a> <td valign="top">truncates the file.
|
|
<tr bgcolor="#f0f0f0"> <td valign="top"><a href="tqfile.html#open">IO_Translate</a> <td valign="top">enables carriage returns and linefeed
|
|
translation for text files under MS-DOS, Windows and Macintosh. On
|
|
Unix systems this flag has no effect. Use with caution as it will
|
|
also transform every linefeed written to the file into a CRLF
|
|
pair. This is likely to corrupt your file if you write write
|
|
binary data. Cannot be combined with <a href="tqfile.html#open">IO_Raw</a>.
|
|
</table></center>
|
|
<p> This virtual function must be reimplemented by all subclasses.
|
|
<p> <p>See also <a href="#close">close</a>().
|
|
|
|
<p>Example: <a href="grapher-nsplugin-example.html#x2743">grapher/grapher.cpp</a>.
|
|
<p>Reimplemented in <a href="tqfile.html#open">TQFile</a> and <a href="tqsocket.html#open">TQSocket</a>.
|
|
<h3 class=fn>int <a name="putch"></a>TQIODevice::putch ( int ch )<tt> [pure virtual]</tt>
|
|
</h3>
|
|
|
|
<p> Writes the character <em>ch</em> to the I/O device.
|
|
<p> Returns <em>ch</em>, or -1 if an error occurred.
|
|
<p> This virtual function must be reimplemented by all subclasses.
|
|
<p> <p>See also <a href="#getch">getch</a>() and <a href="#ungetch">ungetch</a>().
|
|
|
|
<p>Example: <a href="grapher-nsplugin-example.html#x2744">grapher/grapher.cpp</a>.
|
|
<p>Reimplemented in <a href="tqfile.html#putch">TQFile</a> and <a href="tqsocket.html#putch">TQSocket</a>.
|
|
<h3 class=fn><a href="tqbytearray.html">TQByteArray</a> <a name="readAll"></a>TQIODevice::readAll ()<tt> [virtual]</tt>
|
|
</h3>
|
|
This convenience function returns all of the remaining data in the
|
|
device.
|
|
|
|
<h3 class=fn>TQ_LONG <a name="readBlock"></a>TQIODevice::readBlock ( char * data, TQ_ULONG maxlen )<tt> [pure virtual]</tt>
|
|
</h3>
|
|
|
|
<p> Reads at most <em>maxlen</em> bytes from the I/O device into <em>data</em> and
|
|
returns the number of bytes actually read.
|
|
<p> This function should return -1 if a fatal error occurs and should
|
|
return 0 if there are no bytes to read.
|
|
<p> The device must be opened for reading, and <em>data</em> must not be 0.
|
|
<p> This virtual function must be reimplemented by all subclasses.
|
|
<p> <p>See also <a href="#writeBlock">writeBlock</a>(), <a href="#isOpen">isOpen</a>(), and <a href="#isReadable">isReadable</a>().
|
|
|
|
<p>Example: <a href="distributor-example.html#x2667">distributor/distributor.ui.h</a>.
|
|
<p>Reimplemented in <a href="tqsocket.html#readBlock">TQSocket</a> and <a href="tqsocketdevice.html#readBlock">TQSocketDevice</a>.
|
|
<h3 class=fn>TQ_LONG <a name="readLine"></a>TQIODevice::readLine ( char * data, TQ_ULONG maxlen )<tt> [virtual]</tt>
|
|
</h3>
|
|
Reads a line of text, (or up to <em>maxlen</em> bytes if a newline isn't
|
|
encountered) plus a terminating '\0' into <em>data</em>. If there is a
|
|
newline at the end if the line, it is not stripped.
|
|
<p> Returns the number of bytes read including the terminating '\0',
|
|
or -1 if an error occurred.
|
|
<p> This virtual function can be reimplemented much more efficiently
|
|
by the most subclasses.
|
|
<p> <p>See also <a href="#readBlock">readBlock</a>() and <a href="tqtextstream.html#readLine">TQTextStream::readLine</a>().
|
|
|
|
<p>Reimplemented in <a href="tqfile.html#readLine">TQFile</a>.
|
|
<h3 class=fn>bool <a name="reset"></a>TQIODevice::reset ()
|
|
</h3>
|
|
|
|
<p> Sets the device index position to 0.
|
|
<p> <p>See also <a href="#at">at</a>().
|
|
|
|
<h3 class=fn>void <a name="resetStatus"></a>TQIODevice::resetStatus ()
|
|
</h3>
|
|
|
|
<p> Sets the I/O device status to <a href="tqiodevice.html#status">IO_Ok</a>.
|
|
<p> <p>See also <a href="#status">status</a>().
|
|
|
|
<h3 class=fn>void <a name="setFlags"></a>TQIODevice::setFlags ( int flags )<tt> [protected]</tt>
|
|
</h3>
|
|
|
|
<p> Used by subclasses to set the device flags to the <em>flags</em> specified.
|
|
|
|
<h3 class=fn>void <a name="setMode"></a>TQIODevice::setMode ( int mode )<tt> [protected]</tt>
|
|
</h3>
|
|
|
|
<p> Used by subclasses to set the device mode to the <em>mode</em> specified.
|
|
|
|
<h3 class=fn>void <a name="setState"></a>TQIODevice::setState ( int state )<tt> [protected]</tt>
|
|
</h3>
|
|
|
|
<p> Used by subclasses to set the device state to the <em>state</em> specified.
|
|
|
|
<h3 class=fn>void <a name="setStatus"></a>TQIODevice::setStatus ( int s )<tt> [protected]</tt>
|
|
</h3>
|
|
Used by subclasses to set the device status (not state) to <em>s</em>.
|
|
|
|
<h3 class=fn>void <a name="setType"></a>TQIODevice::setType ( int type )<tt> [protected]</tt>
|
|
</h3>
|
|
|
|
<p> Used by subclasses to set the device type to the <em>type</em> specified.
|
|
|
|
<h3 class=fn><a href="tqiodevice.html#Offset">Offset</a> <a name="size"></a>TQIODevice::size () const<tt> [pure virtual]</tt>
|
|
</h3>
|
|
|
|
<p> Virtual function that returns the size of the I/O device.
|
|
<p> <p>See also <a href="#at">at</a>().
|
|
|
|
<p>Reimplemented in <a href="tqfile.html#size">TQFile</a> and <a href="tqsocket.html#size">TQSocket</a>.
|
|
<h3 class=fn>int <a name="state"></a>TQIODevice::state () const
|
|
</h3>
|
|
|
|
<p> Returns bits OR'ed together that specify the current state.
|
|
<p> The flags are: <tt>IO_Open</tt>.
|
|
<p> Subclasses may define additional flags.
|
|
|
|
<h3 class=fn>int <a name="status"></a>TQIODevice::status () const
|
|
</h3>
|
|
|
|
<p> Returns the I/O device status.
|
|
<p> The I/O device status returns an error code. If <a href="#open">open</a>() returns
|
|
FALSE or <a href="#readBlock">readBlock</a>() or <a href="#writeBlock">writeBlock</a>() return -1, this function can
|
|
be called to find out the reason why the operation failed.
|
|
<p> <!-- index IO_Ok --><!-- index IO_ReadError --><!-- index IO_WriteError --><!-- index IO_FatalError --><!-- index IO_OpenError --><!-- index IO_ConnectError --><!-- index IO_AbortError --><!-- index IO_TimeOutError --><!-- index IO_UnspecifiedError -->
|
|
<p> The status codes are:
|
|
<center><table cellpadding="4" cellspacing="2" border="0">
|
|
<tr bgcolor="#a2c511"> <th valign="top">Status code <th valign="top">Meaning
|
|
<tr bgcolor="#f0f0f0"> <td valign="top"><a href="tqiodevice.html#status">IO_Ok</a> <td valign="top">The operation was successful.
|
|
<tr bgcolor="#d0d0d0"> <td valign="top"><a href="tqiodevice.html#status">IO_ReadError</a> <td valign="top">Could not read from the device.
|
|
<tr bgcolor="#f0f0f0"> <td valign="top"><a href="tqiodevice.html#status">IO_WriteError</a> <td valign="top">Could not write to the device.
|
|
<tr bgcolor="#d0d0d0"> <td valign="top"><a href="tqiodevice.html#status">IO_FatalError</a> <td valign="top">A fatal unrecoverable error occurred.
|
|
<tr bgcolor="#f0f0f0"> <td valign="top"><a href="tqiodevice.html#status">IO_OpenError</a> <td valign="top">Could not open the device.
|
|
<tr bgcolor="#d0d0d0"> <td valign="top"><a href="tqiodevice.html#status">IO_ConnectError</a> <td valign="top">Could not connect to the device.
|
|
<tr bgcolor="#f0f0f0"> <td valign="top"><a href="tqiodevice.html#status">IO_AbortError</a> <td valign="top">The operation was unexpectedly aborted.
|
|
<tr bgcolor="#d0d0d0"> <td valign="top"><a href="tqiodevice.html#status">IO_TimeOutError</a> <td valign="top">The operation timed out.
|
|
<tr bgcolor="#f0f0f0"> <td valign="top"><a href="tqiodevice.html#status">IO_UnspecifiedError</a> <td valign="top">An unspecified error happened on close.
|
|
</table></center>
|
|
<p> <p>See also <a href="#resetStatus">resetStatus</a>().
|
|
|
|
<h3 class=fn>int <a name="ungetch"></a>TQIODevice::ungetch ( int ch )<tt> [pure virtual]</tt>
|
|
</h3>
|
|
|
|
<p> Puts the character <em>ch</em> back into the I/O device and decrements
|
|
the index position if it is not zero.
|
|
<p> This function is normally called to "undo" a <a href="#getch">getch</a>() operation.
|
|
<p> Returns <em>ch</em>, or -1 if an error occurred.
|
|
<p> This virtual function must be reimplemented by all subclasses.
|
|
<p> <p>See also <a href="#getch">getch</a>() and <a href="#putch">putch</a>().
|
|
|
|
<p>Reimplemented in <a href="tqfile.html#ungetch">TQFile</a> and <a href="tqsocket.html#ungetch">TQSocket</a>.
|
|
<h3 class=fn>TQ_LONG <a name="writeBlock"></a>TQIODevice::writeBlock ( const char * data, TQ_ULONG len )<tt> [pure virtual]</tt>
|
|
</h3>
|
|
|
|
<p> Writes <em>len</em> bytes from <em>data</em> to the I/O device and returns the
|
|
number of bytes actually written.
|
|
<p> This function should return -1 if a fatal error occurs.
|
|
<p> This virtual function must be reimplemented by all subclasses.
|
|
<p> <p>See also <a href="#readBlock">readBlock</a>().
|
|
|
|
<p>Example: <a href="distributor-example.html#x2668">distributor/distributor.ui.h</a>.
|
|
<p>Reimplemented in <a href="tqbuffer.html#writeBlock">TQBuffer</a>, <a href="tqsocket.html#writeBlock">TQSocket</a>, and <a href="tqsocketdevice.html#writeBlock">TQSocketDevice</a>.
|
|
<h3 class=fn>TQ_LONG <a name="writeBlock-2"></a>TQIODevice::writeBlock ( const <a href="tqbytearray.html">TQByteArray</a> & data )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> This convenience function is the same as calling <a href="#writeBlock">writeBlock</a>(
|
|
data.data(), data.<a href="#size">size</a>() ).
|
|
|
|
<!-- eof -->
|
|
<hr><p>
|
|
This file is part of the <a href="index.html">TQt toolkit</a>.
|
|
Copyright © 1995-2007
|
|
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
|
<table width=100% cellspacing=0 border=0><tr>
|
|
<td>Copyright © 2007
|
|
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
|
<td align=right><div align=right>TQt 3.3.8</div>
|
|
</table></div></address></body>
|
|
</html>
|