29#ifndef SN_XML_DESERIALIZER_H
30#define SN_XML_DESERIALIZER_H
32#include "SnXmlVisitorReader.h"
34namespace physx {
namespace Sn {
37 template<
typename TTriIndexElem>
43 Triangle( TTriIndexElem inIdx0 = 0, TTriIndexElem inIdx1 = 0, TTriIndexElem inIdx2 = 0)
56 PxU8* allocate( PxU32 inSize ) {
return mAllocator->allocate( inSize ); }
57 void deallocate( PxU8* inMem ) { mAllocator->deallocate( inMem ); }
60 inline bool isEmpty(
const char *s)
71 inline void strtoLong(
Triangle<PxU32>& ioDatatype,
const char*& ioData )
73 strto( ioDatatype.mIdx0, ioData );
74 strto( ioDatatype.mIdx1, ioData );
75 strto( ioDatatype.mIdx2, ioData );
78 inline void strtoLong( PxHeightFieldSample& ioDatatype,
const char*& ioData )
81 strto( tempData, ioData );
84 PxU32& theItem(tempData);
86 PxU8* theReadPtr(
reinterpret_cast< PxU8*
>( &theItem ) );
87 PxU8* theWritePtr(
reinterpret_cast< PxU8*
>( &theDest ) );
97 theWritePtr[0] = theReadPtr[2];
98 theWritePtr[1] = theReadPtr[3];
99 theWritePtr[2] = theReadPtr[1];
100 theWritePtr[3] = theReadPtr[0];
103 ioDatatype = *
reinterpret_cast<PxHeightFieldSample*
>( &tempData );
106 template<
typename TDataType>
107 inline void readStridedFlagsProperty( XmlReader& ioReader,
const char* inPropName, TDataType*& outData, PxU32& outStride, PxU32& outCount, XmlMemoryAllocator& inAllocator,
108 const PxU32ToName* inConversions)
110 const char* theSrcData;
111 outStride =
sizeof( TDataType );
114 if ( ioReader.read( inPropName, theSrcData ) )
116 XmlMemoryAllocateMemoryPoolAllocator tempAllocator( &inAllocator );
117 MemoryBufferBase<XmlMemoryAllocateMemoryPoolAllocator> tempBuffer( &tempAllocator );
121 static PxU32 theCount = 0;
123 char* theStartData =
const_cast< char*
>( copyStr( &tempAllocator, theSrcData ) );
124 char* aData = strtok(theStartData,
" \n");
128 stringToFlagsType( aData, inAllocator, tempValue, inConversions );
129 aData = strtok(NULL,
" \n");
130 tempBuffer.write( &tempValue,
sizeof(TDataType) );
132 outData =
reinterpret_cast< TDataType*
>( tempBuffer.mBuffer );
133 outCount = tempBuffer.mWriteOffset /
sizeof( TDataType );
134 tempAllocator.deallocate(
reinterpret_cast<PxU8*
>(theStartData) );
136 tempBuffer.releaseBuffer();
140 template<
typename TDataType>
141 inline void readStridedBufferProperty( XmlReader& ioReader,
const char* inPropName, TDataType*& outData, PxU32& outStride, PxU32& outCount, XmlMemoryAllocator& inAllocator)
143 const char* theSrcData;
144 outStride =
sizeof( TDataType );
147 if ( ioReader.read( inPropName, theSrcData ) )
149 XmlMemoryAllocateMemoryPoolAllocator tempAllocator( &inAllocator );
150 MemoryBufferBase<XmlMemoryAllocateMemoryPoolAllocator> tempBuffer( &tempAllocator );
154 static PxU32 theCount = 0;
156 char* theStartData =
const_cast< char*
>( copyStr( &tempAllocator, theSrcData ) );
157 const char* theData = theStartData;
158 while( !isEmpty(theData) )
162 strtoLong( theType, theData );
163 tempBuffer.write( &theType,
sizeof(theType) );
165 outData =
reinterpret_cast< TDataType*
>( tempBuffer.mBuffer );
166 outCount = tempBuffer.mWriteOffset /
sizeof( TDataType );
167 tempAllocator.deallocate(
reinterpret_cast<PxU8*
>(theStartData) );
169 tempBuffer.releaseBuffer();
173 template<
typename TDataType>
174 inline void readStridedBufferProperty( XmlReader& ioReader,
const char* inPropName, PxStridedData& ioData, PxU32& outCount, XmlMemoryAllocator& inAllocator)
176 TDataType* tempData = NULL;
177 readStridedBufferProperty<TDataType>( ioReader, inPropName, tempData, ioData.stride, outCount, inAllocator );
178 ioData.data = tempData;
181 template<
typename TDataType>
182 inline void readStridedBufferProperty( XmlReader& ioReader,
const char* inPropName, PxTypedStridedData<TDataType>& ioData, PxU32& outCount, XmlMemoryAllocator& inAllocator)
184 TDataType* tempData = NULL;
185 readStridedBufferProperty<TDataType>( ioReader, inPropName, tempData, ioData.stride, outCount, inAllocator );
186 ioData.data =
reinterpret_cast<PxMaterialTableIndex*
>( tempData );
189 template<
typename TDataType>
190 inline void readStridedBufferProperty( XmlReader& ioReader,
const char* inPropName, PxBoundedData& ioData, XmlMemoryAllocator& inAllocator)
192 return readStridedBufferProperty<TDataType>( ioReader, inPropName, ioData, ioData.count, inAllocator );
Definition SnXmlMemoryAllocator.h:37
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition SnippetImmediateMode.cpp:303
Definition SnXmlDeserializer.h:39
Definition SnXmlDeserializer.h:52