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.
149 lines
8.1 KiB
149 lines
8.1 KiB
13 years ago
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||
5 months ago
|
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/tools/tqbuffer.cpp:41 -->
|
||
13 years ago
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||
|
<title>TQBuffer 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>TQBuffer Class Reference</h1>
|
||
|
|
||
|
<p>The TQBuffer class is an I/O device that operates on a TQByteArray.
|
||
|
<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>
|
||
5 months ago
|
<p><tt>#include <<a href="tqbuffer-h.html">tqbuffer.h</a>></tt>
|
||
|
<p>Inherits <a href="tqiodevice.html">TQIODevice</a>.
|
||
|
<p><a href="tqbuffer-members.html">List of all member functions.</a>
|
||
13 years ago
|
<h2>Public Members</h2>
|
||
|
<ul>
|
||
|
<li class=fn><a href="#TQBuffer"><b>TQBuffer</b></a> ()</li>
|
||
|
<li class=fn><a href="#TQBuffer-2"><b>TQBuffer</b></a> ( TQByteArray buf )</li>
|
||
|
<li class=fn><a href="#~TQBuffer"><b>~TQBuffer</b></a> ()</li>
|
||
|
<li class=fn>TQByteArray <a href="#buffer"><b>buffer</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#setBuffer"><b>setBuffer</b></a> ( TQByteArray buf )</li>
|
||
13 years ago
|
<li class=fn>virtual TQ_LONG <a href="#writeBlock"><b>writeBlock</b></a> ( const char * p, TQ_ULONG len )</li>
|
||
|
<li class=fn>TQ_LONG <a href="#writeBlock-2"><b>writeBlock</b></a> ( const TQByteArray & data )</li>
|
||
13 years ago
|
</ul>
|
||
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
||
|
|
||
|
|
||
|
|
||
5 months ago
|
The TQBuffer class is an I/O device that operates on a <a href="tqbytearray.html">TQByteArray</a>.
|
||
13 years ago
|
<p>
|
||
|
|
||
|
<p> TQBuffer is used to read and write to a memory buffer. It is
|
||
5 months ago
|
normally used with a <a href="tqtextstream.html">TQTextStream</a> or a <a href="tqdatastream.html">TQDataStream</a>. TQBuffer has an
|
||
|
associated TQByteArray which holds the buffer data. The <a href="tqiodevice.html#size">size</a>() of
|
||
13 years ago
|
the buffer is automatically adjusted as data is written.
|
||
|
<p> The constructor <tt>TQBuffer(TQByteArray)</tt> creates a TQBuffer using an
|
||
|
existing byte array. The byte array can also be set with
|
||
|
<a href="#setBuffer">setBuffer</a>(). Writing to the TQBuffer will modify the original byte
|
||
|
array because TQByteArray is <a href="shclass.html">explicitly
|
||
|
shared.</a>
|
||
5 months ago
|
<p> Use <a href="tqiodevice.html#open">open</a>() to open the buffer before use and to set the mode
|
||
|
(read-only, write-only, etc.). <a href="tqiodevice.html#close">close</a>() closes the buffer. The
|
||
13 years ago
|
buffer must be closed before reopening or calling setBuffer().
|
||
5 months ago
|
<p> A common way to use TQBuffer is through <a href="tqdatastream.html">TQDataStream</a> or <a href="tqtextstream.html">TQTextStream</a>, which have constructors that take a TQBuffer
|
||
13 years ago
|
parameter. For convenience, there are also TQDataStream and
|
||
5 months ago
|
<a href="tqtextstream.html">TQTextStream</a> constructors that take a <a href="tqbytearray.html">TQByteArray</a> parameter. These
|
||
13 years ago
|
constructors create and open an internal TQBuffer.
|
||
6 months ago
|
<p> Note that TQTextStream can also operate on a <a href="tqstring.html">TQString</a> (a Unicode
|
||
13 years ago
|
string); a TQBuffer cannot.
|
||
5 months ago
|
<p> You can also use TQBuffer directly through the standard <a href="tqiodevice.html">TQIODevice</a>
|
||
|
functions <a href="tqiodevice.html#readBlock">readBlock</a>(), <a href="#writeBlock">writeBlock</a>() <a href="tqiodevice.html#readLine">readLine</a>(), <a href="tqiodevice.html#at">at</a>(), <a href="tqiodevice.html#getch">getch</a>(),
|
||
|
<a href="tqiodevice.html#putch">putch</a>() and <a href="tqiodevice.html#ungetch">ungetch</a>().
|
||
|
<p> <p>See also <a href="tqfile.html">TQFile</a>, <a href="tqdatastream.html">TQDataStream</a>, <a href="tqtextstream.html">TQTextStream</a>, <a href="tqbytearray.html">TQByteArray</a>, <a href="shclass.html">Shared Classes</a>, <a href="collection.html">Collection Classes</a>, and <a href="io.html">Input/Output and Networking</a>.
|
||
13 years ago
|
|
||
|
<hr><h2>Member Function Documentation</h2>
|
||
|
<h3 class=fn><a name="TQBuffer"></a>TQBuffer::TQBuffer ()
|
||
|
</h3>
|
||
|
Constructs an empty buffer.
|
||
|
|
||
5 months ago
|
<h3 class=fn><a name="TQBuffer-2"></a>TQBuffer::TQBuffer ( <a href="tqbytearray.html">TQByteArray</a> buf )
|
||
13 years ago
|
</h3>
|
||
|
Constructs a buffer that operates on <em>buf</em>.
|
||
5 months ago
|
<p> If you open the buffer in write mode (<a href="tqfile.html#open"><a href="tqfile.html#open">IO_WriteOnly</a></a> or
|
||
|
<a href="tqfile.html#open">IO_ReadWrite</a>) and write something into the buffer, <em>buf</em>
|
||
13 years ago
|
will be modified.
|
||
|
<p> Example:
|
||
|
<pre>
|
||
5 months ago
|
<a href="tqcstring.html">TQCString</a> str = "abc";
|
||
13 years ago
|
TQBuffer b( str );
|
||
5 months ago
|
b.<a href="tqiodevice.html#open">open</a>( IO_WriteOnly );
|
||
|
b.<a href="tqiodevice.html#at">at</a>( 3 ); // position at the 4th character (the terminating \0)
|
||
13 years ago
|
b.<a href="#writeBlock">writeBlock</a>( "def", 4 ); // write "def" including the terminating \0
|
||
5 months ago
|
b.<a href="tqiodevice.html#close">close</a>();
|
||
13 years ago
|
// Now, str == "abcdef" with a terminating \0
|
||
|
</pre>
|
||
|
|
||
|
<p> <p>See also <a href="#setBuffer">setBuffer</a>().
|
||
|
|
||
|
<h3 class=fn><a name="~TQBuffer"></a>TQBuffer::~TQBuffer ()
|
||
|
</h3>
|
||
|
Destroys the buffer.
|
||
|
|
||
5 months ago
|
<h3 class=fn><a href="tqbytearray.html">TQByteArray</a> <a name="buffer"></a>TQBuffer::buffer () const
|
||
13 years ago
|
</h3>
|
||
|
|
||
|
<p> Returns this buffer's byte array.
|
||
|
<p> <p>See also <a href="#setBuffer">setBuffer</a>().
|
||
|
|
||
5 months ago
|
<h3 class=fn>bool <a name="setBuffer"></a>TQBuffer::setBuffer ( <a href="tqbytearray.html">TQByteArray</a> buf )
|
||
13 years ago
|
</h3>
|
||
|
Replaces the buffer's contents with <em>buf</em> and returns TRUE.
|
||
5 months ago
|
<p> Does nothing (and returns FALSE) if <a href="tqiodevice.html#isOpen">isOpen</a>() is TRUE.
|
||
|
<p> Note that if you open the buffer in write mode (<a href="tqfile.html#open"><a href="tqfile.html#open">IO_WriteOnly</a></a> or
|
||
|
<a href="tqfile.html#open">IO_ReadWrite</a>) and write something into the buffer, <em>buf</em> is also
|
||
5 months ago
|
modified because <a href="tqbytearray.html">TQByteArray</a> is an <a href="shclass.html#explicitly-shared">explicitly shared</a> class.
|
||
5 months ago
|
<p> <p>See also <a href="#buffer">buffer</a>(), <a href="tqiodevice.html#open">open</a>(), and <a href="tqiodevice.html#close">close</a>().
|
||
13 years ago
|
|
||
13 years ago
|
<h3 class=fn>TQ_LONG <a name="writeBlock"></a>TQBuffer::writeBlock ( const char * p, TQ_ULONG len )<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
Writes <em>len</em> bytes from <em>p</em> into the buffer at the current
|
||
|
index position, overwriting any characters there and extending the
|
||
|
buffer if necessary. Returns the number of bytes actually written.
|
||
|
<p> Returns -1 if an error occurred.
|
||
5 months ago
|
<p> <p>See also <a href="tqiodevice.html#readBlock">readBlock</a>().
|
||
13 years ago
|
|
||
5 months ago
|
<p>Reimplemented from <a href="tqiodevice.html#writeBlock">TQIODevice</a>.
|
||
5 months ago
|
<h3 class=fn>TQ_LONG <a name="writeBlock-2"></a>TQBuffer::writeBlock ( const <a href="tqbytearray.html">TQByteArray</a> & data )
|
||
13 years ago
|
</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
|
||
|
<tt>writeBlock( data.data(), data.size() )</tt> with <em>data</em>.
|
||
|
|
||
|
<!-- 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>
|