KDECore
#include <k3socketbuffer_p.h>
Public Member Functions | |
KSocketBuffer (qint64 size=-1) | |
KSocketBuffer (const KSocketBuffer &other) | |
~KSocketBuffer () | |
bool | canReadLine () const |
void | clear () |
qint64 | consumeBuffer (char *data, qint64 maxlen, bool discard=true) |
qint64 | feedBuffer (const char *data, qint64 len) |
bool | isEmpty () const |
bool | isFull () const |
qint64 | length () const |
KSocketBuffer & | operator= (const KSocketBuffer &other) |
qint64 | readLine (char *data, qint64 maxSize) |
qint64 | receiveFrom (KActiveSocketBase *device, qint64 len=-1) |
qint64 | sendTo (KActiveSocketBase *device, qint64 len=-1) |
bool | setSize (qint64 size) |
qint64 | size () const |
Protected Attributes | |
qint64 | m_length |
QList< QByteArray > | m_list |
QMutex | m_mutex |
qint64 | m_offset |
qint64 | m_size |
Detailed Description
generic socket buffering code
This class implements generic buffering used by KBufferedSocket.
- Deprecated:
- Use KSocketFactory or KLocalSocket instead
Definition at line 48 of file k3socketbuffer_p.h.
Constructor & Destructor Documentation
KSocketBuffer::KSocketBuffer | ( | qint64 | size = -1 | ) |
Default constructor.
- Parameters
-
size the maximum size of the buffer
Definition at line 40 of file k3socketbuffer.cpp.
KSocketBuffer::KSocketBuffer | ( | const KSocketBuffer & | other | ) |
Copy constructor.
Definition at line 45 of file k3socketbuffer.cpp.
KSocketBuffer::~KSocketBuffer | ( | ) |
Virtual destructor.
Frees the buffer and discards its contents.
Definition at line 51 of file k3socketbuffer.cpp.
Member Function Documentation
bool KSocketBuffer::canReadLine | ( | ) | const |
Returns true if a line can be read from the buffer.
Definition at line 69 of file k3socketbuffer.cpp.
void KSocketBuffer::clear | ( | ) |
Clears the buffer.
Definition at line 220 of file k3socketbuffer.cpp.
Consumes data from the beginning of the buffer.
- Parameters
-
data where to copy the data to maxlen the maximum length to copy, in bytes discard if true, the bytes copied will be discarded
- Returns
- the number of bytes copied from the buffer
Definition at line 170 of file k3socketbuffer.cpp.
Adds data to the end of the buffer.
- Parameters
-
data the data to be added len the data length, in bytes
- Returns
- the number of bytes added to the end of the buffer.
Definition at line 150 of file k3socketbuffer.cpp.
|
inline |
Returns true if the buffer is empty of data.
Definition at line 94 of file k3socketbuffer_p.h.
|
inline |
Returns true if the buffer is full (i.e., cannot receive more data)
Definition at line 117 of file k3socketbuffer_p.h.
qint64 KSocketBuffer::length | ( | ) | const |
Returns the number of bytes in the buffer.
Note that this is not the size of the buffer.
- See also
- size
Definition at line 123 of file k3socketbuffer.cpp.
KSocketBuffer & KSocketBuffer::operator= | ( | const KSocketBuffer & | other | ) |
Assignment operator.
Definition at line 56 of file k3socketbuffer.cpp.
Reads a line from the buffer and discard it from the buffer.
Definition at line 88 of file k3socketbuffer.cpp.
qint64 KSocketBuffer::receiveFrom | ( | KActiveSocketBase * | device, |
qint64 | len = -1 |
||
) |
Tries to receive len
bytes of data from the I/O device.
- Parameters
-
device the device to receive from len the number of bytes to receive; -1 to read as much as possible
- Returns
- the number of bytes received and copied into the buffer, -1 indicates an error.
Definition at line 293 of file k3socketbuffer.cpp.
qint64 KSocketBuffer::sendTo | ( | KActiveSocketBase * | device, |
qint64 | len = -1 |
||
) |
Sends at most len
bytes of data to the I/O Device.
- Parameters
-
device the device to which to send data len the amount of data to send; -1 to send everything
- Returns
- the number of bytes sent and discarded from the buffer, -1 indicates an error.
Definition at line 228 of file k3socketbuffer.cpp.
Sets the size of the buffer, if allowed.
- Parameters
-
size the maximum size, use -1 for unlimited.
- Returns
- true on success, false if an error occurred.
- Note
- if the new size is less than length(), the buffer will be truncated
Definition at line 133 of file k3socketbuffer.cpp.
qint64 KSocketBuffer::size | ( | ) | const |
Retrieves the buffer size.
The value of -1 indicates that the buffer has no defined upper limit.
Definition at line 128 of file k3socketbuffer.cpp.
Member Data Documentation
|
mutableprotected |
Definition at line 171 of file k3socketbuffer_p.h.
|
protected |
Definition at line 167 of file k3socketbuffer_p.h.
|
mutableprotected |
Definition at line 166 of file k3socketbuffer_p.h.
|
protected |
offset of the start of data in the first element
Definition at line 168 of file k3socketbuffer_p.h.
|
protected |
the maximum length of the buffer
Definition at line 170 of file k3socketbuffer_p.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:14 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.