00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __XVR2_BUFFER_H__
00015 #define __XVR2_BUFFER_H__
00016
00017 #include <xvr2/DataTypes.h>
00018 #include <xvr2/CoreExceptions.h>
00019 #include <xvr2/Object.h>
00020 #include <xvr2/String.h>
00021
00022 namespace xvr2{
00037 class Buffer : public Object{
00038 private:
00043 bool freeme;
00044 protected:
00050 UInt8 *_data;
00052 UInt32 _size;
00053 public:
00056 Buffer();
00063 Buffer(void *__data, UInt32 __size, bool _freeme = true);
00070 Buffer(const void *__data, UInt32 __size, bool _freeme = false);
00074 Buffer(const Buffer &b);
00080 virtual ~Buffer();
00082 UInt32 size();
00084 UInt32 size() const;
00085
00086
00088 const void *data();
00090 const void *data() const;
00092 const UInt8 operator[](int pos);
00094 const UInt8 operator[](int pos) const;
00096 const UInt8 get(int pos);
00098 const UInt8 get(int pos) const;
00100 const void *getBuf(int pos);
00102 const void *getBuf(int pos) const;
00103 virtual std::string toString();
00104
00105
00107 const Buffer &append(UInt8 v);
00110 const Buffer &append(const void *__data, UInt32 __size);
00112 const Buffer &append(const Buffer &b);
00114 const Buffer &append(const String &s);
00116 const Buffer &operator<<(UInt8 v);
00118 const Buffer &operator<<(const Buffer &b);
00120 const Buffer &operator<<(const String &s);
00121
00122
00125 const Buffer &insert(UInt32 pos, UInt8 v);
00126 const Buffer &insert(UInt32 pos, const void *__data, UInt32 __size);
00127 const Buffer &insert(UInt32 pos, const Buffer &b);
00128 const Buffer &insert(UInt32 pos, const String &s);
00129
00130
00131
00132
00135 Buffer cloneMe();
00138 static Buffer clone(const Buffer &b);
00139
00140
00144 const Buffer ©(const Buffer &b);
00145 const Buffer ©(const void *__data, UInt32 __size);
00146 const Buffer ©(UInt8 v);
00147 const Buffer ©(const String &s);
00148 const Buffer &assign(const Buffer &b);
00149 const Buffer &assign(const void *__data, UInt32 __size);
00150 const Buffer &assign(UInt8 v);
00151 const Buffer &assign(const String &s);
00152
00153
00155 Buffer ref();
00157 const Buffer &refTo(const Buffer &b);
00163 const Buffer &refTo(void *_buf, UInt32 _siz, bool __f = false);
00164
00165
00167 void empty();
00168 void clear();
00169 };
00170
00171 }
00172
00173 #endif