29#ifndef SN_XML_MEMORY_POOL_STREAMS_H
30#define SN_XML_MEMORY_POOL_STREAMS_H
32#include "foundation/PxTransform.h"
33#include "foundation/PxIO.h"
34#include "SnXmlMemoryPool.h"
38 template<
typename TDataType>
41 bool force_compile_error;
45#define XML_DEFINE_DEFAULT_VALUE(type, defVal ) \
47 struct XmlDefaultValue<type> \
49 type getDefaultValue() { return type(defVal); } \
52 XML_DEFINE_DEFAULT_VALUE(PxU8, 0)
53 XML_DEFINE_DEFAULT_VALUE(PxI8, 0)
54 XML_DEFINE_DEFAULT_VALUE(PxU16, 0)
55 XML_DEFINE_DEFAULT_VALUE(PxI16, 0)
56 XML_DEFINE_DEFAULT_VALUE(PxU32, 0)
57 XML_DEFINE_DEFAULT_VALUE(PxI32, 0)
58 XML_DEFINE_DEFAULT_VALUE(PxU64, 0)
59 XML_DEFINE_DEFAULT_VALUE(PxI64, 0)
60 XML_DEFINE_DEFAULT_VALUE(PxF32, 0)
61 XML_DEFINE_DEFAULT_VALUE(PxF64, 0)
63#undef XML_DEFINE_DEFAULT_VALUE
90template<
typename TAllocatorType>
93 TAllocatorType* mManager;
94 mutable PxU32 mWriteOffset;
95 mutable PxU32 mReadOffset;
101 : mManager( inManager )
110 mManager->deallocate( mBuffer );
112 PxU8* releaseBuffer()
116 PxU8* retval(mBuffer);
122 mWriteOffset = mReadOffset = 0;
125 virtual PxU32
read(
void* dest, PxU32 count)
127 bool fits = ( mReadOffset + count ) <= mWriteOffset;
131 PxMemCopy( dest, mBuffer + mReadOffset, count );
132 mReadOffset += count;
138 inline void checkCapacity( PxU32 inNewCapacity )
140 if ( mCapacity < inNewCapacity )
142 PxU32 newCapacity = 32;
143 while( newCapacity < inNewCapacity )
144 newCapacity = newCapacity << 1;
146 PxU8* newData( mManager->allocate( newCapacity ) );
148 PxMemCopy( newData, mBuffer, mWriteOffset );
149 mManager->deallocate( mBuffer );
151 mCapacity = newCapacity;
155 virtual PxU32
write(
const void* src, PxU32 count)
157 checkCapacity( mWriteOffset + count );
158 PxMemCopy( mBuffer + mWriteOffset, src, count );
159 mWriteOffset += count;
Definition SnXmlMemoryPool.h:246
Definition SnXmlMemoryPoolStreams.h:165
Output stream class for I/O.
Definition PxIO.h:114
This is a quaternion class. For more information on quaternion mathematics consult a mathematics sour...
Definition PxQuat.h:50
3 Element vector class.
Definition PxVec3.h:50
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_FORCE_INLINE void * PxMemCopy(void *dest, const void *src, PxU32 count)
Copies the bytes of one memory block to another. The memory blocks must not overlap.
Definition PxMemory.h:83
Definition SnXmlMemoryPoolStreams.h:92
virtual PxU32 read(void *dest, PxU32 count)
read from the stream. The number of bytes read may be less than the number requested.
Definition SnXmlMemoryPoolStreams.h:125
virtual PxU32 write(const void *src, PxU32 count)
write to the stream. The number of bytes written may be less than the number sent.
Definition SnXmlMemoryPoolStreams.h:155
Definition SnXmlMemoryPoolStreams.h:40