• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • KNetwork
  • Internal
  • KSocketBuffer
Public Member Functions | Protected Attributes | List of all members
KNetwork::Internal::KSocketBuffer Class Reference

#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.

Author
Thiago Macieira thiag.nosp@m.o@kd.nosp@m.e.org
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
sizethe 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.

qint64 KSocketBuffer::consumeBuffer ( char *  data,
qint64  maxlen,
bool  discard = true 
)

Consumes data from the beginning of the buffer.

Parameters
datawhere to copy the data to
maxlenthe maximum length to copy, in bytes
discardif true, the bytes copied will be discarded
Returns
the number of bytes copied from the buffer

Definition at line 170 of file k3socketbuffer.cpp.

qint64 KSocketBuffer::feedBuffer ( const char *  data,
qint64  len 
)

Adds data to the end of the buffer.

Parameters
datathe data to be added
lenthe data length, in bytes
Returns
the number of bytes added to the end of the buffer.

Definition at line 150 of file k3socketbuffer.cpp.

bool KNetwork::Internal::KSocketBuffer::isEmpty ( ) const
inline

Returns true if the buffer is empty of data.

Definition at line 94 of file k3socketbuffer_p.h.

bool KNetwork::Internal::KSocketBuffer::isFull ( ) const
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.

qint64 KSocketBuffer::readLine ( char *  data,
qint64  maxSize 
)

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
devicethe device to receive from
lenthe 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
devicethe device to which to send data
lenthe 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.

bool KSocketBuffer::setSize ( qint64  size)

Sets the size of the buffer, if allowed.

Parameters
sizethe 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.

See also
length for the length of the data stored

Definition at line 128 of file k3socketbuffer.cpp.

Member Data Documentation

qint64 KNetwork::Internal::KSocketBuffer::m_length
mutableprotected

Definition at line 171 of file k3socketbuffer_p.h.

QList<QByteArray> KNetwork::Internal::KSocketBuffer::m_list
protected

Definition at line 167 of file k3socketbuffer_p.h.

QMutex KNetwork::Internal::KSocketBuffer::m_mutex
mutableprotected

Definition at line 166 of file k3socketbuffer_p.h.

qint64 KNetwork::Internal::KSocketBuffer::m_offset
protected

offset of the start of data in the first element

Definition at line 168 of file k3socketbuffer_p.h.

qint64 KNetwork::Internal::KSocketBuffer::m_size
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:
  • k3socketbuffer_p.h
  • k3socketbuffer.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:12 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal