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.
571 lines
33 KiB
571 lines
33 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/tqdatastream.cpp:51 -->
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>TQDataStream 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>TQDataStream Class Reference</h1>
|
|
|
|
<p>The TQDataStream class provides serialization of binary data
|
|
to a TQIODevice.
|
|
<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="tqdatastream-h.html">tqdatastream.h</a>></tt>
|
|
<p><a href="tqdatastream-members.html">List of all member functions.</a>
|
|
<h2>Public Members</h2>
|
|
<ul>
|
|
<li class=fn><a href="#TQDataStream"><b>TQDataStream</b></a> ()</li>
|
|
<li class=fn><a href="#TQDataStream-2"><b>TQDataStream</b></a> ( TQIODevice * d )</li>
|
|
<li class=fn><a href="#TQDataStream-3"><b>TQDataStream</b></a> ( TQByteArray a, int mode )</li>
|
|
<li class=fn>virtual <a href="#~TQDataStream"><b>~TQDataStream</b></a> ()</li>
|
|
<li class=fn>TQIODevice * <a href="#device"><b>device</b></a> () const</li>
|
|
<li class=fn>void <a href="#setDevice"><b>setDevice</b></a> ( TQIODevice * d )</li>
|
|
<li class=fn>void <a href="#unsetDevice"><b>unsetDevice</b></a> ()</li>
|
|
<li class=fn>bool <a href="#atEnd"><b>atEnd</b></a> () const</li>
|
|
<li class=fn>bool eof () const <em>(obsolete)</em></li>
|
|
<li class=fn>enum <a href="#ByteOrder-enum"><b>ByteOrder</b></a> { BigEndian, LittleEndian }</li>
|
|
<li class=fn>int <a href="#byteOrder"><b>byteOrder</b></a> () const</li>
|
|
<li class=fn>void <a href="#setByteOrder"><b>setByteOrder</b></a> ( int bo )</li>
|
|
<li class=fn>bool <a href="#isPrintableData"><b>isPrintableData</b></a> () const</li>
|
|
<li class=fn>void <a href="#setPrintableData"><b>setPrintableData</b></a> ( bool enable )</li>
|
|
<li class=fn>int <a href="#version"><b>version</b></a> () const</li>
|
|
<li class=fn>void <a href="#setVersion"><b>setVersion</b></a> ( int v )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( TQ_INT8 & i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt-2"><b>operator>></b></a> ( TQ_UINT8 & i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt-3"><b>operator>></b></a> ( TQ_INT16 & i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt-4"><b>operator>></b></a> ( TQ_UINT16 & i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt-5"><b>operator>></b></a> ( TQ_INT32 & i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt-6"><b>operator>></b></a> ( TQ_UINT32 & i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt-7"><b>operator>></b></a> ( TQ_INT64 & i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt-8"><b>operator>></b></a> ( TQ_UINT64 & i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt-9"><b>operator>></b></a> ( TQ_LONG & i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt-a"><b>operator>></b></a> ( TQ_ULONG & i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt-b"><b>operator>></b></a> ( float & f )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt-c"><b>operator>></b></a> ( double & f )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt-d"><b>operator>></b></a> ( char *& s )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( TQ_INT8 i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt-2"><b>operator<<</b></a> ( TQ_UINT8 i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt-3"><b>operator<<</b></a> ( TQ_INT16 i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt-4"><b>operator<<</b></a> ( TQ_UINT16 i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt-5"><b>operator<<</b></a> ( TQ_INT32 i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt-6"><b>operator<<</b></a> ( TQ_UINT32 i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt-7"><b>operator<<</b></a> ( TQ_INT64 i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt-8"><b>operator<<</b></a> ( TQ_UINT64 i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt-9"><b>operator<<</b></a> ( TQ_LONG i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt-a"><b>operator<<</b></a> ( TQ_ULONG i )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt-b"><b>operator<<</b></a> ( float f )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt-c"><b>operator<<</b></a> ( double f )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt-d"><b>operator<<</b></a> ( const char * s )</li>
|
|
<li class=fn>TQDataStream & <a href="#readBytes"><b>readBytes</b></a> ( char *& s, uint & l )</li>
|
|
<li class=fn>TQDataStream & <a href="#readRawBytes"><b>readRawBytes</b></a> ( char * s, uint len )</li>
|
|
<li class=fn>TQDataStream & <a href="#writeBytes"><b>writeBytes</b></a> ( const char * s, uint len )</li>
|
|
<li class=fn>TQDataStream & <a href="#writeRawBytes"><b>writeRawBytes</b></a> ( const char * s, uint len )</li>
|
|
</ul>
|
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
|
|
|
|
|
|
|
The TQDataStream class provides serialization of binary data
|
|
to a <a href="tqiodevice.html">TQIODevice</a>.
|
|
<p>
|
|
<p> A data stream is a binary stream of encoded information which is
|
|
100% independent of the host computer's operating system, CPU or
|
|
byte order. For example, a data stream that is written by a PC
|
|
under Windows can be read by a Sun SPARC running Solaris.
|
|
<p> You can also use a data stream to read/write <a href="#raw">raw
|
|
unencoded binary data</a>. If you want a "parsing" input
|
|
stream, see <a href="tqtextstream.html">TQTextStream</a>.
|
|
<p> The TQDataStream class implements the serialization of C++'s basic
|
|
data types, like <tt>char</tt>, <tt>short</tt>, <tt>int</tt>, <tt>char*</tt>, etc.
|
|
Serialization of more complex data is accomplished by breaking up
|
|
the data into primitive units.
|
|
<p> A data stream cooperates closely with a TQIODevice. A TQIODevice
|
|
represents an input/output medium one can read data from and write
|
|
data to. The <a href="tqfile.html">TQFile</a> class is an example of an IO device.
|
|
<p> Example (write binary data to a stream):
|
|
<pre>
|
|
<a href="tqfile.html">TQFile</a> file( "file.dat" );
|
|
file.<a href="tqfile.html#open">open</a>( <a href="tqfile.html#open">IO_WriteOnly</a> );
|
|
TQDataStream stream( &file ); // we will serialize the data into the file
|
|
stream << "the answer is"; // serialize a string
|
|
stream << (TQ_INT32)42; // serialize an integer
|
|
</pre>
|
|
|
|
<p> Example (read binary data from a stream):
|
|
<pre>
|
|
<a href="tqfile.html">TQFile</a> file( "file.dat" );
|
|
file.<a href="tqfile.html#open">open</a>( <a href="tqfile.html#open">IO_ReadOnly</a> );
|
|
TQDataStream stream( &file ); // read the data serialized from the file
|
|
<a href="tqstring.html">TQString</a> str;
|
|
TQ_INT32 a;
|
|
stream >> str >> a; // extract "the answer is" and 42
|
|
</pre>
|
|
|
|
<p> Each item written to the stream is written in a predefined binary
|
|
format that varies depending on the item's type. Supported TQt
|
|
types include <a href="tqbrush.html">TQBrush</a>, <a href="tqcolor.html">TQColor</a>, <a href="tqdatetime.html">TQDateTime</a>, <a href="tqfont.html">TQFont</a>, <a href="tqpixmap.html">TQPixmap</a>, <a href="tqstring.html">TQString</a>,
|
|
<a href="ntqvariant.html">TQVariant</a> and many others. For the complete list of all TQt types
|
|
supporting data streaming see the <a href="datastreamformat.html">Format of the TQDataStream operators</a>.
|
|
<p> For integers it is best to always cast to a TQt integer type for
|
|
writing, and to read back into the same TQt integer type. This
|
|
ensures that you get integers of the size you want and insulates
|
|
you from compiler and platform differences.
|
|
<p> To take one example, a <tt>char*</tt> string is written as a 32-bit
|
|
integer equal to the length of the string including the NUL byte
|
|
('\0'), followed by all the characters of the string including the
|
|
NUL byte. When reading a <tt>char*</tt> string, 4 bytes are read to
|
|
create the 32-bit length value, then that many characters for the
|
|
<tt>char*</tt> string including the NUL are read.
|
|
<p> The initial IODevice is usually set in the constructor, but can be
|
|
changed with <a href="#setDevice">setDevice</a>(). If you've reached the end of the data
|
|
(or if there is no IODevice set) <a href="#atEnd">atEnd</a>() will return TRUE.
|
|
<p> If you want the data to be compatible with an earlier version of
|
|
TQt use <a href="#setVersion">setVersion</a>().
|
|
<p> If you want the data to be human-readable, e.g. for debugging, you
|
|
can set the data stream into printable data mode with
|
|
<a href="#setPrintableData">setPrintableData</a>(). The data is then written slower, in a bloated
|
|
but human readable format.
|
|
<p> If you are producing a new binary data format, such as a file
|
|
format for documents created by your application, you could use a
|
|
TQDataStream to write the data in a portable format. Typically, you
|
|
would write a brief header containing a magic string and a version
|
|
number to give yourself room for future expansion. For example:
|
|
<p> <pre>
|
|
<a href="tqfile.html">TQFile</a> file( "file.xxx" );
|
|
file.<a href="tqfile.html#open">open</a>( IO_WriteOnly );
|
|
TQDataStream stream( &file );
|
|
|
|
// Write a header with a "magic number" and a version
|
|
stream << (TQ_UINT32)0xA0B0C0D0;
|
|
stream << (TQ_INT32)123;
|
|
|
|
// Write the data
|
|
stream << [lots of interesting data]
|
|
</pre>
|
|
|
|
<p> Then read it in with:
|
|
<p> <pre>
|
|
<a href="tqfile.html">TQFile</a> file( "file.xxx" );
|
|
file.<a href="tqfile.html#open">open</a>( IO_ReadOnly );
|
|
TQDataStream stream( &file );
|
|
|
|
// Read and check the header
|
|
TQ_UINT32 magic;
|
|
stream >> magic;
|
|
if ( magic != 0xA0B0C0D0 )
|
|
return XXX_BAD_FILE_FORMAT;
|
|
|
|
// Read the version
|
|
TQ_INT32 version;
|
|
stream >> version;
|
|
if ( version < 100 )
|
|
return XXX_BAD_FILE_TOO_OLD;
|
|
if ( version > 123 )
|
|
return XXX_BAD_FILE_TOO_NEW;
|
|
if ( version <= 110 )
|
|
stream.<a href="#setVersion">setVersion</a>(1);
|
|
|
|
// Read the data
|
|
stream >> [lots of interesting data];
|
|
if ( version > 120 )
|
|
stream >> [data new in XXX version 1.2];
|
|
stream >> [other interesting data];
|
|
</pre>
|
|
|
|
<p> You can select which byte order to use when serializing data. The
|
|
default setting is big endian (MSB first). Changing it to little
|
|
endian breaks the portability (unless the reader also changes to
|
|
little endian). We recommend keeping this setting unless you have
|
|
special requirements.
|
|
<p> <a name="raw"></a>
|
|
<h3> Reading and writing raw binary data
|
|
</h3>
|
|
<a name="1"></a><p> You may wish to read/write your own raw binary data to/from the
|
|
data stream directly. Data may be read from the stream into a
|
|
preallocated char* using <a href="#readRawBytes">readRawBytes</a>(). Similarly data can be
|
|
written to the stream using <a href="#writeRawBytes">writeRawBytes</a>(). Notice that any
|
|
encoding/decoding of the data must be done by you.
|
|
<p> A similar pair of functions is <a href="#readBytes">readBytes</a>() and <a href="#writeBytes">writeBytes</a>(). These
|
|
differ from their <em>raw</em> counterparts as follows: readBytes()
|
|
reads a TQ_UINT32 which is taken to be the length of the data to be
|
|
read, then that number of bytes is read into the preallocated
|
|
char*; writeBytes() writes a TQ_UINT32 containing the length of the
|
|
data, followed by the data. Notice that any encoding/decoding of
|
|
the data (apart from the length TQ_UINT32) must be done by you.
|
|
<p> <p>See also <a href="tqtextstream.html">TQTextStream</a>, <a href="ntqvariant.html">TQVariant</a>, and <a href="io.html">Input/Output and Networking</a>.
|
|
|
|
<hr><h2>Member Type Documentation</h2>
|
|
<h3 class=fn><a name="ByteOrder-enum"></a>TQDataStream::ByteOrder</h3>
|
|
|
|
<p> The byte order used for reading/writing the data.
|
|
<ul>
|
|
<li><tt>TQDataStream::BigEndian</tt> - the default
|
|
<li><tt>TQDataStream::LittleEndian</tt>
|
|
</ul>
|
|
<hr><h2>Member Function Documentation</h2>
|
|
<h3 class=fn><a name="TQDataStream"></a>TQDataStream::TQDataStream ()
|
|
</h3>
|
|
Constructs a data stream that has no IO device.
|
|
<p> <p>See also <a href="#setDevice">setDevice</a>().
|
|
|
|
<h3 class=fn><a name="TQDataStream-2"></a>TQDataStream::TQDataStream ( <a href="tqiodevice.html">TQIODevice</a> * d )
|
|
</h3>
|
|
Constructs a data stream that uses the IO device <em>d</em>.
|
|
<p> <b>Warning:</b> If you use <a href="tqsocket.html">TQSocket</a> or <a href="tqsocketdevice.html">TQSocketDevice</a> as the IO device <em>d</em>
|
|
for reading data, you must make sure that enough data is available
|
|
on the socket for the operation to successfully proceed;
|
|
TQDataStream does not have any means to handle or recover from
|
|
short-reads.
|
|
<p> <p>See also <a href="#setDevice">setDevice</a>() and <a href="#device">device</a>().
|
|
|
|
<h3 class=fn><a name="TQDataStream-3"></a>TQDataStream::TQDataStream ( <a href="tqbytearray.html">TQByteArray</a> a, int mode )
|
|
</h3>
|
|
Constructs a data stream that operates on a byte array, <em>a</em>,
|
|
through an internal <a href="tqbuffer.html">TQBuffer</a> device. The <em>mode</em> is a
|
|
<a href="tqiodevice.html#mode">TQIODevice::mode</a>(), usually either <a href="tqfile.html#open">IO_ReadOnly</a> or <a href="tqfile.html#open">IO_WriteOnly</a>.
|
|
<p> Example:
|
|
<pre>
|
|
static char bindata[] = { 231, 1, 44, ... };
|
|
<a href="tqbytearray.html">TQByteArray</a> a;
|
|
a.<a href="tqmemarray.html#setRawData">setRawData</a>( bindata, sizeof(bindata) ); // a points to bindata
|
|
TQDataStream stream( a, <a href="tqfile.html#open">IO_ReadOnly</a> ); // open on a's data
|
|
stream >> [something]; // read raw bindata
|
|
a.<a href="tqmemarray.html#resetRawData">resetRawData</a>( bindata, sizeof(bindata) ); // finished
|
|
</pre>
|
|
|
|
<p> The <a href="tqmemarray.html#setRawData">TQByteArray::setRawData</a>() function is not for the inexperienced.
|
|
|
|
<h3 class=fn><a name="~TQDataStream"></a>TQDataStream::~TQDataStream ()<tt> [virtual]</tt>
|
|
</h3>
|
|
Destroys the data stream.
|
|
<p> The destructor will not affect the current IO device, unless it is
|
|
an internal IO device processing a <a href="tqbytearray.html">TQByteArray</a> passed in the <em>constructor</em>, in which case the internal IO device is destroyed.
|
|
|
|
<h3 class=fn>bool <a name="atEnd"></a>TQDataStream::atEnd () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the IO device has reached the end position (end of
|
|
the stream or file) or if there is no IO device set; otherwise
|
|
returns FALSE, i.e. if the current position of the IO device is
|
|
before the end position.
|
|
<p> <p>See also <a href="tqiodevice.html#atEnd">TQIODevice::atEnd</a>().
|
|
|
|
<h3 class=fn>int <a name="byteOrder"></a>TQDataStream::byteOrder () const
|
|
</h3>
|
|
|
|
<p> Returns the current byte order setting -- either <a href="#ByteOrder-enum">BigEndian</a> or
|
|
<a href="#ByteOrder-enum">LittleEndian</a>.
|
|
<p> <p>See also <a href="#setByteOrder">setByteOrder</a>().
|
|
|
|
<h3 class=fn><a href="tqiodevice.html">TQIODevice</a> * <a name="device"></a>TQDataStream::device () const
|
|
</h3>
|
|
|
|
<p> Returns the IO device currently set.
|
|
<p> <p>See also <a href="#setDevice">setDevice</a>() and <a href="#unsetDevice">unsetDevice</a>().
|
|
|
|
<h3 class=fn>bool <a name="eof"></a>TQDataStream::eof () const
|
|
</h3>
|
|
<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
|
<p> Returns TRUE if the IO device has reached the end position (end of
|
|
stream or file) or if there is no IO device set.
|
|
<p> Returns FALSE if the current position of the read/write head of the IO
|
|
device is somewhere before the end position.
|
|
<p> <p>See also <a href="tqiodevice.html#atEnd">TQIODevice::atEnd</a>().
|
|
|
|
<h3 class=fn>bool <a name="isPrintableData"></a>TQDataStream::isPrintableData () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the printable data flag has been set; otherwise
|
|
returns FALSE.
|
|
<p> <p>See also <a href="#setPrintableData">setPrintableData</a>().
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt"></a>TQDataStream::operator<< ( TQ_INT8 i )
|
|
</h3>
|
|
Writes a signed byte, <em>i</em>, to the stream and returns a reference
|
|
to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-2"></a>TQDataStream::operator<< ( TQ_UINT8 i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Writes an unsigned byte, <em>i</em>, to the stream and returns a
|
|
reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-3"></a>TQDataStream::operator<< ( TQ_INT16 i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Writes a signed 16-bit integer, <em>i</em>, to the stream and returns a
|
|
reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-4"></a>TQDataStream::operator<< ( TQ_UINT16 i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Writes an unsigned 16-bit integer, <em>i</em>, to the stream and returns
|
|
a reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-5"></a>TQDataStream::operator<< ( TQ_INT32 i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Writes a signed 32-bit integer, <em>i</em>, to the stream and returns a
|
|
reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-6"></a>TQDataStream::operator<< ( TQ_UINT32 i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Writes an unsigned integer, <em>i</em>, to the stream as a 32-bit
|
|
unsigned integer (TQ_UINT32). Returns a reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-7"></a>TQDataStream::operator<< ( TQ_INT64 i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Writes a signed 64-bit integer, <em>i</em>, to the stream and returns a
|
|
reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-8"></a>TQDataStream::operator<< ( TQ_UINT64 i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Writes an unsigned 64-bit integer, <em>i</em>, to the stream and returns a
|
|
reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-9"></a>TQDataStream::operator<< ( TQ_LONG i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Writes a signed integer <em>i</em>, of the system's word length, to the
|
|
stream and returns a reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-a"></a>TQDataStream::operator<< ( TQ_ULONG i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Writes an unsigned integer <em>i</em>, of the system's word length, to
|
|
the stream and returns a reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-b"></a>TQDataStream::operator<< ( float f )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Writes a 32-bit floating point number, <em>f</em>, to the stream using
|
|
the standard IEEE754 format. Returns a reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-c"></a>TQDataStream::operator<< ( double f )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Writes a 64-bit floating point number, <em>f</em>, to the stream using
|
|
the standard IEEE754 format. Returns a reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-d"></a>TQDataStream::operator<< ( const char * s )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Writes the '\0'-terminated string <em>s</em> to the stream and returns a
|
|
reference to the stream.
|
|
<p> The string is serialized using <a href="#writeBytes">writeBytes</a>().
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt"></a>TQDataStream::operator>> ( TQ_INT8 & i )
|
|
</h3>
|
|
Reads a signed byte from the stream into <em>i</em>, and returns a
|
|
reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt-2"></a>TQDataStream::operator>> ( TQ_UINT8 & i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Reads an unsigned byte from the stream into <em>i</em>, and returns a
|
|
reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt-3"></a>TQDataStream::operator>> ( TQ_INT16 & i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Reads a signed 16-bit integer from the stream into <em>i</em>, and
|
|
returns a reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt-4"></a>TQDataStream::operator>> ( TQ_UINT16 & i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Reads an unsigned 16-bit integer from the stream into <em>i</em>, and
|
|
returns a reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt-5"></a>TQDataStream::operator>> ( TQ_INT32 & i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Reads a signed 32-bit integer from the stream into <em>i</em>, and
|
|
returns a reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt-6"></a>TQDataStream::operator>> ( TQ_UINT32 & i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Reads an unsigned 32-bit integer from the stream into <em>i</em>, and
|
|
returns a reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt-7"></a>TQDataStream::operator>> ( TQ_INT64 & i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Reads a signed 64-bit integer from the stream into <em>i</em>, and
|
|
returns a reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt-8"></a>TQDataStream::operator>> ( TQ_UINT64 & i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Reads an unsigned 64-bit integer from the stream, into <em>i</em>, and
|
|
returns a reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt-9"></a>TQDataStream::operator>> ( TQ_LONG & i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Reads a signed integer of the system's word length from the stream
|
|
into <em>i</em>, and returns a reference to the stream.
|
|
<p>
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt-a"></a>TQDataStream::operator>> ( TQ_ULONG & i )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Reads an unsigned integer of the system's word length from the
|
|
stream, into <em>i</em>, and returns a reference to the stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt-b"></a>TQDataStream::operator>> ( float & f )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Reads a 32-bit floating point number from the stream into <em>f</em>,
|
|
using the standard IEEE754 format. Returns a reference to the
|
|
stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt-c"></a>TQDataStream::operator>> ( double & f )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Reads a 64-bit floating point number from the stream into <em>f</em>,
|
|
using the standard IEEE754 format. Returns a reference to the
|
|
stream.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt-d"></a>TQDataStream::operator>> ( char *& s )
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Reads the '\0'-terminated string <em>s</em> from the stream and returns
|
|
a reference to the stream.
|
|
<p> Space for the string is allocated using <tt>new</tt> -- the caller must
|
|
destroy it with delete[].
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="readBytes"></a>TQDataStream::readBytes ( char *& s, uint & l )
|
|
</h3>
|
|
Reads the buffer <em>s</em> from the stream and returns a reference to
|
|
the stream.
|
|
<p> The buffer <em>s</em> is allocated using <tt>new</tt>. Destroy it with the <tt>delete[]</tt> operator. If the length is zero or <em>s</em> cannot be
|
|
allocated, <em>s</em> is set to 0.
|
|
<p> The <em>l</em> parameter will be set to the length of the buffer.
|
|
<p> The serialization format is a TQ_UINT32 length specifier first,
|
|
then <em>l</em> bytes of data. Note that the data is <em>not</em> encoded.
|
|
<p> <p>See also <a href="#readRawBytes">readRawBytes</a>() and <a href="#writeBytes">writeBytes</a>().
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="readRawBytes"></a>TQDataStream::readRawBytes ( char * s, uint len )
|
|
</h3>
|
|
Reads <em>len</em> bytes from the stream into <em>s</em> and returns a
|
|
reference to the stream.
|
|
<p> The buffer <em>s</em> must be preallocated. The data is <em>not</em> encoded.
|
|
<p> <p>See also <a href="#readBytes">readBytes</a>(), <a href="tqiodevice.html#readBlock">TQIODevice::readBlock</a>(), and <a href="#writeRawBytes">writeRawBytes</a>().
|
|
|
|
<h3 class=fn>void <a name="setByteOrder"></a>TQDataStream::setByteOrder ( int bo )
|
|
</h3>
|
|
Sets the serialization byte order to <em>bo</em>.
|
|
<p> The <em>bo</em> parameter can be <a href="#ByteOrder-enum">TQDataStream::BigEndian</a> or <a href="#ByteOrder-enum">TQDataStream::LittleEndian</a>.
|
|
<p> The default setting is big endian. We recommend leaving this
|
|
setting unless you have special requirements.
|
|
<p> <p>See also <a href="#byteOrder">byteOrder</a>().
|
|
|
|
<h3 class=fn>void <a name="setDevice"></a>TQDataStream::setDevice ( <a href="tqiodevice.html">TQIODevice</a> * d )
|
|
</h3>
|
|
void <a href="#setDevice">TQDataStream::setDevice</a>(<a href="tqiodevice.html">TQIODevice</a> *d )
|
|
<p> Sets the IO device to <em>d</em>.
|
|
<p> <p>See also <a href="#device">device</a>() and <a href="#unsetDevice">unsetDevice</a>().
|
|
|
|
<h3 class=fn>void <a name="setPrintableData"></a>TQDataStream::setPrintableData ( bool enable )
|
|
</h3>
|
|
|
|
<p> If <em>enable</em> is TRUE, data will be output in a human readable
|
|
format. If <em>enable</em> is FALSE, data will be output in a binary
|
|
format.
|
|
<p> If <em>enable</em> is TRUE, the write functions will generate output
|
|
that consists of printable characters (7 bit ASCII). This output
|
|
will typically be a lot larger than the default binary output, and
|
|
consequently slower to write.
|
|
<p> We recommend only enabling printable data for debugging purposes.
|
|
|
|
<h3 class=fn>void <a name="setVersion"></a>TQDataStream::setVersion ( int v )
|
|
</h3>
|
|
|
|
<p> Sets the version number of the data serialization format to <em>v</em>.
|
|
<p> You don't need to set a version if you are using the current
|
|
version of TQt.
|
|
<p> In order to accommodate new functionality, the datastream
|
|
serialization format of some TQt classes has changed in some
|
|
versions of TQt. If you want to read data that was created by an
|
|
earlier version of TQt, or write data that can be read by a program
|
|
that was compiled with an earlier version of TQt, use this function
|
|
to modify the serialization format of TQDataStream.
|
|
<p> <center><table cellpadding="4" cellspacing="2" border="0">
|
|
<tr bgcolor="#a2c511"> <th valign="top">TQt Version <th valign="top">TQDataStream Version
|
|
<tr bgcolor="#f0f0f0"> <td valign="top">TQt 3.3 <td valign="top" colspan="1" rowspan="1"> 6
|
|
<tr bgcolor="#d0d0d0"> <td valign="top">TQt 3.2 <td valign="top" colspan="1" rowspan="1"> 5
|
|
<tr bgcolor="#f0f0f0"> <td valign="top">TQt 3.1 <td valign="top" colspan="1" rowspan="1"> 5
|
|
<tr bgcolor="#d0d0d0"> <td valign="top">TQt 3.0 <td valign="top" colspan="1" rowspan="1"> 4
|
|
<tr bgcolor="#f0f0f0"> <td valign="top">TQt 2.1.x and TQt 2.2.x <td valign="top" colspan="1" rowspan="1"> 3
|
|
<tr bgcolor="#d0d0d0"> <td valign="top">TQt 2.0.x <td valign="top" colspan="1" rowspan="1"> 2
|
|
<tr bgcolor="#f0f0f0"> <td valign="top">TQt 1.x <td valign="top" colspan="1" rowspan="1"> 1
|
|
</table></center>
|
|
<p> <p>See also <a href="#version">version</a>().
|
|
|
|
<h3 class=fn>void <a name="unsetDevice"></a>TQDataStream::unsetDevice ()
|
|
</h3>
|
|
Unsets the IO device. This is the same as calling <a href="#setDevice">setDevice</a>( 0 ).
|
|
<p> <p>See also <a href="#device">device</a>() and <a href="#setDevice">setDevice</a>().
|
|
|
|
<h3 class=fn>int <a name="version"></a>TQDataStream::version () const
|
|
</h3>
|
|
|
|
<p> Returns the version number of the data serialization format. In TQt
|
|
3.1, this number is 5.
|
|
<p> <p>See also <a href="#setVersion">setVersion</a>().
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="writeBytes"></a>TQDataStream::writeBytes ( const char * s, uint len )
|
|
</h3>
|
|
Writes the length specifier <em>len</em> and the buffer <em>s</em> to the
|
|
stream and returns a reference to the stream.
|
|
<p> The <em>len</em> is serialized as a TQ_UINT32, followed by <em>len</em> bytes
|
|
from <em>s</em>. Note that the data is <em>not</em> encoded.
|
|
<p> <p>See also <a href="#writeRawBytes">writeRawBytes</a>() and <a href="#readBytes">readBytes</a>().
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="writeRawBytes"></a>TQDataStream::writeRawBytes ( const char * s, uint len )
|
|
</h3>
|
|
Writes <em>len</em> bytes from <em>s</em> to the stream and returns a
|
|
reference to the stream. The data is <em>not</em> encoded.
|
|
<p> <p>See also <a href="#writeBytes">writeBytes</a>(), <a href="tqiodevice.html#writeBlock">TQIODevice::writeBlock</a>(), and <a href="#readRawBytes">readRawBytes</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>
|