32#include "SnXmlMemoryPool.h"
33#include "foundation/PxString.h"
34#include "foundation/PxMemory.h"
36namespace physx {
namespace Sn {
38typedef CMemoryPoolManager TMemoryPoolManager;
42 inline PxU32 strLen(
const char* inStr )
56 inline const char* copyStr( PxAllocatorCallback& inAllocator,
const char* inStr )
58 if ( inStr && *inStr )
60 PxU32 theLen = snXmlImpl::strLen( inStr );
63 char* dest =
reinterpret_cast<char*
>( inAllocator.allocate( theLen + 1,
"Repx::const char*", __FILE__, __LINE__ ) );
71 template<
typename TManagerType>
72 inline const char* copyStr( TManagerType* inMgr,
const char* inStr )
74 if ( inStr && *inStr )
76 PxU32 theLen = snXmlImpl::strLen( inStr );
77 char* dest =
reinterpret_cast<char*
>( inMgr->allocate( theLen + 1 ) );
85 inline void releaseStr( TMemoryPoolManager* inMgr,
const char* inStr, PxU32 )
87 if ( inStr && *inStr )
89 inMgr->deallocate(
reinterpret_cast< PxU8*
>(
const_cast<char*
>( inStr ) ) );
93 inline void releaseStr( TMemoryPoolManager* inMgr,
const char* inStr )
95 if ( inStr && *inStr )
97 PxU32 theLen = snXmlImpl::strLen( inStr );
98 releaseStr( inMgr, inStr, theLen );
117 mPreviousSibling = NULL;
127 void addChild(
XmlNode* inItem )
129 inItem->mParent =
this;
130 if ( mFirstChild == NULL )
131 mFirstChild = inItem;
134 XmlNode* theNode = mFirstChild;
136 while( theNode->mNextSibling != NULL )
137 theNode = theNode->mNextSibling;
138 theNode->mNextSibling = inItem;
139 inItem->mPreviousSibling = theNode;
145 for (
XmlNode* theNode = mFirstChild; theNode; theNode = theNode->mNextSibling )
147 XmlNode* theRepXNode = theNode;
148 if ( physx::Pxstricmp( theRepXNode->mName, inName ) == 0 )
158 if ( mParent->mFirstChild ==
this )
159 mParent->mFirstChild = mNextSibling;
161 if ( mPreviousSibling )
162 mPreviousSibling->mNextSibling = mNextSibling;
164 mNextSibling->mPreviousSibling = mPreviousSibling;
166 mFirstChild->mParent = NULL;
174 retval->mName = copyStr( inManager, inName );
175 retval->mData = copyStr( inManager, inData );
187 inManager->deallocate( inNode );
190 static PX_INLINE void releaseNodeAndChildren( TMemoryPoolManager* inManager, XmlNode* inNode )
192 if ( inNode->mFirstChild )
194 XmlNode* childNode( inNode->mFirstChild );
197 XmlNode* _node( childNode );
198 childNode = _node->mNextSibling;
199 releaseNodeAndChildren( inManager, _node );
203 release( inManager, inNode );
206 static XmlNode* copyRepXNodeAndSiblings( TMemoryPoolManager* inManager,
const XmlNode* inNode, XmlNode* inParent );
208 static XmlNode* copyRepXNode( TMemoryPoolManager* inManager,
const XmlNode* inNode, XmlNode* inParent = NULL )
210 XmlNode* newNode( allocateRepXNode( inManager, NULL, NULL ) );
211 newNode->mName = inNode->mName;
212 newNode->mData = inNode->mData;
213 newNode->mParent = inParent;
214 if ( inNode->mFirstChild )
215 newNode->mFirstChild = copyRepXNodeAndSiblings( inManager, inNode->mFirstChild, newNode );
219 static XmlNode* copyRepXNodeAndSiblings( TMemoryPoolManager* inManager,
const XmlNode* inNode, XmlNode* inParent )
221 XmlNode* sibling = inNode->mNextSibling;
222 if ( sibling ) sibling = copyRepXNodeAndSiblings( inManager, sibling, inParent );
223 XmlNode* newNode = copyRepXNode( inManager, inNode, inParent );
224 newNode->mNextSibling = sibling;
225 if ( sibling ) sibling->mPreviousSibling = newNode;
229 inline bool isBigEndian() {
int i = 1;
return *(
reinterpret_cast<char*
>(&i))==0; }
Definition SnXmlMemoryPool.h:246
#define PX_INLINE
Definition PxPreprocessor.h:320
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 SnXmlImpl.h:233
Definition SnXmlImpl.h:103
Helper struct to encapsulate the array.
Definition PxProfileAllocatorWrapper.h:152