Buffer.h

Go to the documentation of this file.
00001 /*
00002  * $Id: Buffer.h 562 2007-12-02 08:04:16Z mindstorm2600 $
00003  *
00004  * X-VR2 
00005  * 
00006  * Copyright (C) Juan V. Guerrero 2007
00007  * 
00008  * Juan V. Guerrero <mindstorm2600@users.sourceforge.net>
00009  * 
00010  * This program is free software, distributed under the terms of
00011  * the GNU General Public License Version 2. See the LICENSE file
00012  * at the top of the source tree.
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                         //Read data
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                         //Append data
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                         //Insert data
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                         //Remove data portions
00131                         
00132                         //Cloning
00135                         Buffer cloneMe();
00138                         static Buffer clone(const Buffer &b);
00139                         
00140                         //Copy/Assign
00144                         const Buffer &copy(const Buffer &b);
00145                         const Buffer &copy(const void *__data, UInt32 __size);
00146                         const Buffer &copy(UInt8 v);
00147                         const Buffer &copy(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                         //Referencing
00155                         Buffer ref();
00157                         const Buffer &refTo(const Buffer &b);
00163                         const Buffer &refTo(void *_buf, UInt32 _siz, bool __f = false);
00164                         
00165                         //Empty
00167                         void empty();
00168                         void clear();
00169         };
00170 
00171 }
00172 
00173 #endif

Generated on Fri Jun 20 22:55:47 2008 for X-VR2 SDK by  doxygen 1.5.5