1QBuffer(3qt)                                                      QBuffer(3qt)
2
3
4

NAME

6       QBuffer - I/O device that operates on a QByteArray
7

SYNOPSIS

9       All the functions in this class are reentrant when Qt is built with
10       thread support.</p>
11
12       #include <qbuffer.h>
13
14       Inherits QIODevice.
15
16   Public Members
17       QBuffer ()
18       QBuffer ( QByteArray buf )
19       ~QBuffer ()
20       QByteArray buffer () const
21       bool setBuffer ( QByteArray buf )
22       virtual Q_LONG writeBlock ( const char * p, Q_ULONG len )
23       Q_LONG writeBlock ( const QByteArray & data )
24

DESCRIPTION

26       The QBuffer class is an I/O device that operates on a QByteArray.
27
28       QBuffer is used to read and write to a memory buffer. It is normally
29       used with a QTextStream or a QDataStream. QBuffer has an associated
30       QByteArray which holds the buffer data. The size() of the buffer is
31       automatically adjusted as data is written.
32
33       The constructor QBuffer(QByteArray) creates a QBuffer using an existing
34       byte array. The byte array can also be set with setBuffer(). Writing to
35       the QBuffer will modify the original byte array because QByteArray is
36       explicitly shared.
37
38       Use open() to open the buffer before use and to set the mode (read-
39       only, write-only, etc.). close() closes the buffer. The buffer must be
40       closed before reopening or calling setBuffer().
41
42       A common way to use QBuffer is through QDataStream or QTextStream,
43       which have constructors that take a QBuffer parameter. For convenience,
44       there are also QDataStream and QTextStream constructors that take a
45       QByteArray parameter. These constructors create and open an internal
46       QBuffer.
47
48       Note that QTextStream can also operate on a QString (a Unicode string);
49       a QBuffer cannot.
50
51       You can also use QBuffer directly through the standard QIODevice
52       functions readBlock(), writeBlock() readLine(), at(), getch(), putch()
53       and ungetch().
54
55       See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes,
56       Collection Classes, and Input/Output and Networking.
57

MEMBER FUNCTION DOCUMENTATION

QBuffer::QBuffer ()

60       Constructs an empty buffer.
61

QBuffer::QBuffer ( QByteArray buf )

63       Constructs a buffer that operates on buf.
64
65       If you open the buffer in write mode (<a
66       href="qfile.html#open">IO_WriteOnly</a> or IO_ReadWrite) and write
67       something into the buffer, buf will be modified.
68
69       Example:
70
71           QCString str = "abc";
72           QBuffer b( str );
73           b.open( IO_WriteOnly );
74           b.at( 3 ); // position at the 4th character (the terminating \0)
75           b.writeBlock( "def", 4 ); // write "def" including the terminating \0
76           b.close();
77           // Now, str == "abcdef" with a terminating \0
78
79       See also setBuffer().
80

QBuffer::~QBuffer ()

82       Destroys the buffer.
83

QByteArray QBuffer::buffer () const

85       Returns this buffer's byte array.
86
87       See also setBuffer().
88

bool QBuffer::setBuffer ( QByteArray buf )

90       Replaces the buffer's contents with buf and returns TRUE.
91
92       Does nothing (and returns FALSE) if isOpen() is TRUE.
93
94       Note that if you open the buffer in write mode (<a
95       href="qfile.html#open">IO_WriteOnly</a> or IO_ReadWrite) and write
96       something into the buffer, buf is also modified because QByteArray is
97       an explicitly shared class.
98
99       See also buffer(), open(), and close().
100

Q_LONG QBuffer::writeBlock ( const char * p, Q_ULONG len ) [virtual]

102       Writes len bytes from p into the buffer at the current index position,
103       overwriting any characters there and extending the buffer if necessary.
104       Returns the number of bytes actually written.
105
106       Returns -1 if an error occurred.
107
108       See also readBlock().
109
110       Reimplemented from QIODevice.
111

Q_LONG QBuffer::writeBlock ( const QByteArray & data )

113       This is an overloaded member function, provided for convenience. It
114       behaves essentially like the above function.
115
116       This convenience function is the same as calling writeBlock(
117       data.data(), data.size() ) with data.
118
119

SEE ALSO

121       http://doc.trolltech.com/qbuffer.html
122       http://www.trolltech.com/faq/tech.html
123
125       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
126       license file included in the distribution for a complete license
127       statement.
128

AUTHOR

130       Generated automatically from the source code.
131

BUGS

133       If you find a bug in Qt, please report it as described in
134       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
135       help you. Thank you.
136
137       The definitive Qt documentation is provided in HTML format; it is
138       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
139       web browser. This man page is provided as a convenience for those users
140       who prefer man pages, although this format is not officially supported
141       by Trolltech.
142
143       If you find errors in this manual page, please report them to qt-
144       bugs@trolltech.com.  Please include the name of the manual page
145       (qbuffer.3qt) and the Qt version (3.3.8).
146
147
148
149Trolltech AS                    2 February 2007                   QBuffer(3qt)
Impressum