bytebuffer.h

00001 /***************************************************************************
00002 *   Copyright (C) 2005 by                                                 *
00003 *   Alejandro Perez Mendez     alejandro_perez@dif.um.es                  *
00004 *   Pedro J. Fernandez Ruiz    pedroj.fernandez@dif.um.es                 *
00005 *                                                                         *
00006 *   This library is free software; you can redistribute it and/or         *
00007 *   modify it under the terms of the GNU Lesser General Public            *
00008 *   License as published by the Free Software Foundation; either          *
00009 *   version 2.1 of the License, or (at your option) any later version.    *
00010 *                                                                         *
00011 *   This library is distributed in the hope that it will be useful,       *
00012 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014 *   Lesser General Public License for more details.                       *
00015 *                                                                         *
00016 *   You should have received a copy of the GNU Lesser General Public      *
00017 *   License along with this library; if not, write to the Free Software   *
00018 *   Foundation, Inc., 51 Franklin St, Fifth Floor,                        *
00019 *   Boston, MA  02110-1301  USA                                           *
00020 ***************************************************************************/
00021 #ifndef BYTEBUFFER_H
00022 #define BYTEBUFFER_H
00023 
00024 
00025 #ifdef HAVE_CONFIG_H
00026 #include "config.h"
00027 #endif
00028 
00029 #include <iostream>
00030 #include <cstdlib>
00031 
00032 #include "bytearray.h"
00033 
00034 using namespace std;
00035 
00036 namespace openikev2 {
00037 
00042     class ByteBuffer : public ByteArray {
00043 
00044             /****************************** ATTRIBUTES ******************************/
00045         protected:
00046             uint8_t* real_begin_array;      
00048             /****************************** METHODS ******************************/
00049         protected:
00054             virtual uint32_t capacity() const;
00055 
00056         public:
00061             ByteBuffer( uint32_t capacity );
00062 
00067             ByteBuffer( const ByteBuffer& other );
00068             
00073             ByteBuffer( const ByteArray& byte_array);
00074 
00080             virtual void writeBuffer( const void* buffer, uint32_t buffer_size );
00081 
00086             virtual void writeByteArray( const ByteArray& byte_array );
00087 
00092             virtual void writeInt8( uint8_t value );
00093 
00098             virtual void writeInt16( uint16_t value );
00099 
00104             virtual void writeInt32( uint32_t value );
00105 
00111             virtual void fillBytes( uint32_t num_bytes, uint8_t byte );
00112 
00118             virtual void readBuffer( uint32_t size_to_read, void* destination_buffer );
00119 
00125             virtual auto_ptr<ByteArray> readByteArray( uint32_t size );
00126 
00131             virtual uint8_t readInt8();
00132 
00137             virtual uint16_t readInt16();
00138 
00143             virtual uint32_t readInt32();
00144 
00149             virtual uint8_t* getWritePosition() const;
00150 
00155             virtual void setWritePosition( uint8_t* position );
00156 
00161             virtual uint8_t* getReadPosition() const;
00162 
00167             virtual void setReadPosition( uint8_t* position );
00168 
00172             virtual void reset();
00173 
00178             virtual void skip( uint32_t bytes );
00179 
00180             virtual ~ByteBuffer();
00181     };
00182 }
00183 
00184 #endif

Generated on Fri Jul 27 11:04:44 2007 for libopenikev2 by  doxygen 1.5.1