Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages
parasiticdatabuffer.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2005 by Jorrit Tyberghein 00003 (C) 2005 by Frank Richter 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00024 #ifndef __CS_CSUTIL_PARASITICDATABUFFER_H__ 00025 #define __CS_CSUTIL_PARASITICDATABUFFER_H__ 00026 00027 #include "csextern.h" 00028 #include "pooledscfclass.h" 00029 #include "iutil/databuff.h" 00030 00031 class csParasiticDataBufferBase : public iDataBuffer 00032 { 00033 protected: 00034 csRef<iDataBuffer> parentBuffer; 00035 uint8* data; 00036 size_t size; 00037 00038 void SetContents (iDataBuffer* parent, size_t offs, size_t size) 00039 { 00040 parentBuffer = parent; 00041 data = parent->GetUint8 () + offs; 00042 size_t parRemaining = parent->GetSize () - offs; 00043 if (size == (size_t)~0) 00044 csParasiticDataBufferBase::size = parRemaining; 00045 else 00046 csParasiticDataBufferBase::size = MIN(size, parRemaining); 00047 } 00048 00049 csParasiticDataBufferBase (iDataBuffer* parent, size_t offs, 00050 size_t size = (size_t)~0) 00051 { 00052 SetContents (parent, offs, size); 00053 } 00054 00055 csParasiticDataBufferBase () : data(0), size(0) {} 00056 public: 00057 virtual ~csParasiticDataBufferBase () { } 00058 00059 virtual size_t GetSize () const 00060 { return size; } 00061 virtual char* GetData () const 00062 { return (char*)data; } 00063 inline char *operator * () const 00064 { return (char *)GetData (); } 00065 inline int8* GetInt8 () 00066 { return (int8 *)GetData (); } 00067 inline uint8* GetUint8 () 00068 { return (uint8 *)GetData (); } 00069 }; 00070 00074 class CS_CSUTIL_EXPORT csParasiticDataBuffer : public csParasiticDataBufferBase 00075 { 00076 public: 00077 SCF_DECLARE_IBASE; 00078 00087 csParasiticDataBuffer (iDataBuffer* parent, size_t offs, 00088 size_t size = (size_t)~0) : csParasiticDataBufferBase (parent, offs, size) 00089 { 00090 SCF_CONSTRUCT_IBASE(0); 00091 } 00092 00093 virtual ~csParasiticDataBuffer () 00094 { 00095 SCF_DESTRUCT_IBASE(); 00096 } 00097 }; 00098 00113 class CS_CSUTIL_EXPORT csParasiticDataBufferPooled : 00114 public csParasiticDataBufferBase 00115 { 00116 public: 00117 SCF_DECLARE_IBASE_POOLED_EXTERN(CS_CSUTIL_EXPORT, 00118 csParasiticDataBufferPooled); 00119 00124 void SetContents (iDataBuffer* parent, size_t offs, 00125 size_t size = (size_t)~0) 00126 { 00127 csParasiticDataBufferBase::SetContents (parent, offs, size); 00128 } 00129 protected: 00130 csParasiticDataBufferPooled (Pool* pool) : csParasiticDataBufferBase() 00131 { 00132 SCF_CONSTRUCT_IBASE_POOLED (pool); 00133 } 00134 }; 00135 00136 #endif // __CS_CSUTIL_PARASITICDATABUFFER_H__
Generated for Crystal Space by doxygen 1.3.9.1