Logo Search packages:      
Sourcecode: kmess version File versions  Download package

kmessbuffer.h

/***************************************************************************
                          kmessbuffer.h -  description
                             -------------------
    begin                : Sat July 2 2005
    copyright            : (C) 2003 by Mike K. Bennett
                           (C) 2005 by Diederik van der Boor
    email                : mkb137b@hotmail.com
                           vdboor --at-- codingdomain.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KMESSBUFFER_H
#define KMESSBUFFER_H

#include <qcstring.h>


/**
 * A buffer where received data can be stored and analysed.
 *
 * @author Mike K. Bennett (original work), Diederik van der Boor (made separate class)
 * @ingroup NetworkCore
 */
00032 class KMessBuffer : public QByteArray
{
  public:
    // Constructor
                           KMessBuffer( const uint size = 0 );
    // Destructor
    virtual               ~KMessBuffer();
    // Add data
    void                   add( const char *data, const uint datasize );
    // Retrieve data (peek), warn if the blockSize is larger then the buffer size
    QByteArray             left( const unsigned int blockSize ) const;
    // Retrieve data (read), return the number of bytes actually written. Removes the bytes from the buffer too.
    int                    readBlock( char *buffer, const uint size );
    // Remove read data
    void                   remove( uint blockSize );
    // Find a newline character
    int                    findNewline() const;
    // Return the length of the buffer
    uint                   length() const;
};

#endif

Generated by  Doxygen 1.6.0   Back to index