Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _BDBUFFER_H
00034 #define _BDBUFFER_H
00035
00036 #ifdef HAVE_CONFIG_H
00037 #include <config.h>
00038 #endif
00039
00040 #ifdef HAVE_INTTYPES_H
00041 # include <inttypes.h>
00042 #endif
00043
00044 #ifdef HAVE_STDLIB_h
00045 # include <stdlib.h>
00046 #endif
00047
00048 #ifdef HAVE_STDEXCEPT
00049 # include <stdexcept>
00050 #endif
00051
00052 #include "yapetexception.h"
00053
00054 namespace YAPET {
00071 class BDBuffer {
00072 private:
00078 uint32_t _size;
00079
00085 uint8_t* data;
00086
00087 protected:
00089 uint8_t* alloc_mem (uint32_t s) throw (YAPETException);
00091 void free_mem (uint8_t* d, uint32_t s);
00092
00093 public:
00095 BDBuffer (uint32_t is) throw (YAPETException);
00096 BDBuffer();
00097 BDBuffer (const BDBuffer& ed) throw (YAPETException);
00099 ~BDBuffer();
00100
00102 void resize (uint32_t ns) throw (YAPETException);
00111 uint32_t size() const {
00112 return _size;
00113 }
00114
00116 uint8_t* at (uint32_t pos) throw (std::out_of_range);
00118 const uint8_t* at (uint32_t pos) const throw (std::out_of_range);
00119
00121 const uint8_t* operator() () const {
00122 return data;
00123 }
00125 uint8_t* operator() () {
00126 return data;
00127 }
00128
00130 operator uint8_t*() {
00131 return data;
00132 }
00134 operator const uint8_t*() const {
00135 return data;
00136 }
00137
00139 operator const void*() {
00140 return (void*) data;
00141 }
00142
00143 const BDBuffer& operator= (const BDBuffer& ed);
00144
00145 };
00146
00147 }
00148
00149 #endif // _BDBUFFER_H