summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/tqbuffer.3qt
blob: 4eeaee57d130c26ece2040eb56f19fb7aa5e8aad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
'\" t
.TH TQBuffer 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA.  All rights reserved.  See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
TQBuffer \- I/O device that operates on a TQByteArray
.SH SYNOPSIS
All the functions in this class are reentrant when TQt is built with thread support.</p>
.PP
\fC#include <tqbuffer.h>\fR
.PP
Inherits TQIODevice.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBTQBuffer\fR ()"
.br
.ti -1c
.BI "\fBTQBuffer\fR ( TQByteArray buf )"
.br
.ti -1c
.BI "\fB~TQBuffer\fR ()"
.br
.ti -1c
.BI "TQByteArray \fBbuffer\fR () const"
.br
.ti -1c
.BI "bool \fBsetBuffer\fR ( TQByteArray buf )"
.br
.ti -1c
.BI "virtual TQ_LONG \fBwriteBlock\fR ( const char * p, TQ_ULONG len )"
.br
.ti -1c
.BI "TQ_LONG \fBwriteBlock\fR ( const TQByteArray & data )"
.br
.in -1c
.SH DESCRIPTION
The TQBuffer class is an I/O device that operates on a TQByteArray.
.PP
TQBuffer is used to read and write to a memory buffer. It is normally used with a TQTextStream or a TQDataStream. TQBuffer has an associated TQByteArray which holds the buffer data. The size() of the buffer is automatically adjusted as data is written.
.PP
The constructor \fCTQBuffer(TQByteArray)\fR creates a TQBuffer using an existing byte array. The byte array can also be set with setBuffer(). Writing to the TQBuffer will modify the original byte array because TQByteArray is explicitly shared.
.PP
Use open() to open the buffer before use and to set the mode (read-only, write-only, etc.). close() closes the buffer. The buffer must be closed before reopening or calling setBuffer().
.PP
A common way to use TQBuffer is through TQDataStream or TQTextStream, which have constructors that take a TQBuffer parameter. For convenience, there are also TQDataStream and TQTextStream constructors that take a TQByteArray parameter. These constructors create and open an internal TQBuffer.
.PP
Note that TQTextStream can also operate on a TQString (a Unicode string); a TQBuffer cannot.
.PP
You can also use TQBuffer directly through the standard TQIODevice functions readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().
.PP
See also TQFile, TQDataStream, TQTextStream, TQByteArray, Shared Classes, Collection Classes, and Input/Output and Networking.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "TQBuffer::TQBuffer ()"
Constructs an empty buffer.
.SH "TQBuffer::TQBuffer ( TQByteArray buf )"
Constructs a buffer that operates on \fIbuf\fR.
.PP
If you open the buffer in write mode (<a href="tqfile.html#open">IO_WriteOnly</a> or IO_ReadWrite) and write something into the buffer, \fIbuf\fR will be modified.
.PP
Example:
.PP
.nf
.br
    TQCString str = "abc";
.br
    TQBuffer b( str );
.br
    b.open( IO_WriteOnly );
.br
    b.at( 3 ); // position at the 4th character (the terminating \\0)
.br
    b.writeBlock( "def", 4 ); // write "def" including the terminating \\0
.br
    b.close();
.br
    // Now, str == "abcdef" with a terminating \\0
.br
.fi
.PP
See also setBuffer().
.SH "TQBuffer::~TQBuffer ()"
Destroys the buffer.
.SH "TQByteArray TQBuffer::buffer () const"
Returns this buffer's byte array.
.PP
See also setBuffer().
.SH "bool TQBuffer::setBuffer ( TQByteArray buf )"
Replaces the buffer's contents with \fIbuf\fR and returns TRUE.
.PP
Does nothing (and returns FALSE) if isOpen() is TRUE.
.PP
Note that if you open the buffer in write mode (<a href="tqfile.html#open">IO_WriteOnly</a> or IO_ReadWrite) and write something into the buffer, \fIbuf\fR is also modified because TQByteArray is an explicitly shared class.
.PP
See also buffer(), open(), and close().
.SH "TQ_LONG TQBuffer::writeBlock ( const char * p, TQ_ULONG len )\fC [virtual]\fR"
Writes \fIlen\fR bytes from \fIp\fR 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.
.PP
Returns -1 if an error occurred.
.PP
See also readBlock().
.PP
Reimplemented from TQIODevice.
.SH "TQ_LONG TQBuffer::writeBlock ( const TQByteArray & data )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
This convenience function is the same as calling
\fCwriteBlock( data.data(), data.size() )\fR with \fIdata\fR.

.SH "SEE ALSO"
.BR http://doc.trolltech.com/tqbuffer.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech. 
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqbuffer.3qt) and the Qt
version (3.3.8).