Sources/CcgDump/CryBoneDesc.cpp
// Serializes the description:
// returns the number of required bytes for serialization, if the data pointer is NULL
// returns 0 (if the buffer size is not enough) or the number of bytes written, if the data pointer is given

Serializes the description:
returns the number of required bytes for serialization, if the data pointer is NULL
returns 0 (if the buffer size is not enough) or the number of bytes written, if the data pointer is given
Serializes the description : returns the number of required bytes for serialization if the data pointer is NULL returns 0 ( if the buffer size is not enough ) or the number of bytes written if the data pointer is given
unsigned CryBoneDesc::Serialize (bool bSave, void *pStream, unsigned nSize)
{
	if (bSave)
	{
		unsigned nSizeRequired = (unsigned)(sizeof(CryBoneDescData_Comp) + align4 (m_strName.length()+1));
		if (!pStream)
			return nSizeRequired;
		if (nSize < nSizeRequired)
			return 0;
		CopyCryBone(*(CryBoneDescData_Comp*)pStream, *this);
		memcpy ((CryBoneDescData_Comp*)pStream+1,m_strName.c_str(),m_strName.length()+1);
		return nSizeRequired;
	}
	else
	{
		if (!pStream)
			return 0;
		if (nSize < sizeof(CryBoneDescData_Comp)+1)
			return 0;
		if (nSize & 3)
			return 0; 
		CopyCryBone(*this, *(CryBoneDescData_Comp*)pStream);
		const char* pEnd = (const char*)pStream + nSize;
		const char* pName = (const char*)((CryBoneDescData_Comp*)pStream+1);
		const char *pNameEnd;
		for (pNameEnd = pName; pNameEnd < pEnd && *pNameEnd; ++pNameEnd);
		m_strName.assign (pName, pNameEnd);
		return min(nSize, (unsigned)align4 (pNameEnd+1-(const char*)pStream));
	}
}
unsigned CryBoneDesc :: Serialize ( bool bSave , void * pStream , unsigned nSize ) { if ( bSave ) { unsigned nSizeRequired = ( unsigned ) ( sizeof ( CryBoneDescData_Comp ) + align4 ( m_strName . length ( ) + 1 ) ) ; if ( ! pStream ) return nSizeRequired ; if ( nSize < nSizeRequired ) return 0 ; CopyCryBone ( * ( CryBoneDescData_Comp * ) pStream , * this ) ; memcpy ( ( CryBoneDescData_Comp * ) pStream + 1 , m_strName . c_str ( ) , m_strName . length ( ) + 1 ) ; return nSizeRequired ; } else { if ( ! pStream ) return 0 ; if ( nSize < sizeof ( CryBoneDescData_Comp ) + 1 ) return 0 ; if ( nSize & 3 ) return 0 ; CopyCryBone ( * this , * ( CryBoneDescData_Comp * ) pStream ) ; const char * pEnd = ( const char * ) pStream + nSize ; const char * pName = ( const char * ) ( ( CryBoneDescData_Comp * ) pStream + 1 ) ; const char * pNameEnd ; for ( pNameEnd = pName ; pNameEnd < pEnd && * pNameEnd ; ++ pNameEnd ) ; m_strName . assign ( pName , pNameEnd ) ; return min ( nSize , ( unsigned ) align4 ( pNameEnd + 1 - ( const char * ) pStream ) ) ; } }
Serializes the description:
returns the number of required bytes for serialization, if the data pointer is NULL
returns 0 (if the buffer size is not enough) or the number of bytes written, if the data pointer is given
Serializes the description : returns the number of required bytes for serialization if the data pointer is NULL returns 0 ( if the buffer size is not enough ) or the number of bytes written if the data pointer is given
// alignment error
 // end of the stream
 // the start byte of the bone name
 // scan until the end of the name (\0 char) or the stream (pEnd address)
 // return aligned size of the chunk including the string 0 terminator, but
 // no more than the declared size of the stream
