コード例 #1
0
void CUtlBufferEditor::SeekPut( SeekType_t type, int offset )	
{
	int nNextPut = m_Put;
	switch( type )
	{
	case SEEK_HEAD:						 
		nNextPut = offset; 
		break;

	case SEEK_CURRENT:
		nNextPut += offset;
		break;

	case SEEK_TAIL:
		nNextPut = m_nMaxPut - offset;
		break;
	}

	// Force a write of the data
	// FIXME: We could make this more optimal potentially by writing out
	// the entire buffer if you seek outside the current range

	// NOTE: This call will write and will also seek the file to nNextPut.
	OnPutOverflow( -nNextPut-1 );
	m_Put = nNextPut;

	AddNullTermination();
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Serialization
//-----------------------------------------------------------------------------
void CUtlBufferEditor::Put( const void *pMem, int size )
{
	if ( size && CheckPut( size ) )
	{
		memcpy( &m_Memory[m_Put - m_nOffset], pMem, size );
		m_Put += size;

		AddNullTermination();
	}
}
コード例 #3
0
//-----------------------------------------------------------------------------
// Attaches the buffer to external memory....
//-----------------------------------------------------------------------------
void CUtlBufferEditor::SetExternalBuffer( void* pMemory, int nSize, int nInitialPut, int nFlags )
{
	m_Memory.SetExternalBuffer( (unsigned char*)pMemory, nSize );

	// Reset all indices; we just changed memory
	m_Get = 0;
	m_Put = nInitialPut;
	m_nTab = 0;
	m_Error = 0;
	m_nOffset = 0;
	m_Flags = nFlags;
	m_nMaxPut = -1;
	AddNullTermination();
}
コード例 #4
0
//-----------------------------------------------------------------------------
// Assumes an external buffer but manages its deletion
//-----------------------------------------------------------------------------
void CUtlBufferEditor::AssumeMemory( void *pMemory, int nSize, int nInitialPut, int nFlags )
{
#ifdef SHADER_EDITOR_DLL_2006
	Assert(0);
#else
	m_Memory.AssumeMemory( (unsigned char*) pMemory, nSize );
#endif

	// Reset all indices; we just changed memory
	m_Get = 0;
	m_Put = nInitialPut;
	m_nTab = 0;
	m_Error = 0;
	m_nOffset = 0;
	m_Flags = nFlags;
	m_nMaxPut = -1;
	AddNullTermination();
}
コード例 #5
0
CUtlBufferEditor::CUtlBufferEditor( int growSize, int initSize, int nFlags ) : 
	m_Memory( growSize, initSize ), m_Error(0)
{
	m_Get = 0;
	m_Put = 0;
	m_nTab = 0;
	m_nOffset = 0;
	m_Flags = nFlags;
	if ( (initSize != 0) && !IsReadOnly() )
	{
		m_nMaxPut = -1;
		AddNullTermination();
	}
	else
	{
		m_nMaxPut = 0;
	}
	SetOverflowFuncs( &CUtlBufferEditor::GetOverflow, &CUtlBufferEditor::PutOverflow );
}
コード例 #6
0
ファイル: utlbuffer.cpp プロジェクト: TotallyMehis/ZM-Updated
void CUtlBuffer::SeekPut( SeekType_t type, int offset )	
{
	switch( type )
	{
	case SEEK_HEAD:						 
		m_Put = offset; 
		break;

	case SEEK_CURRENT:
		m_Put += offset;
		break;

	case SEEK_TAIL:
		m_Put = m_nMaxPut - offset;
		break;
	}

	AddNullTermination();
}
コード例 #7
0
CUtlBufferEditor::CUtlBufferEditor( const void *pBuffer, int nSize, int nFlags ) :
	m_Memory( (unsigned char*)pBuffer, nSize ), m_Error(0)
{
//	Assert( nSize != 0 );

	m_Get = 0;
	m_Put = 0;
	m_nTab = 0;
	m_nOffset = 0;
	m_Flags = nFlags;
	if ( IsReadOnly() )
	{
		m_nMaxPut = nSize;
	}
	else
	{
		m_nMaxPut = -1;
		AddNullTermination();
	}
	SetOverflowFuncs( &CUtlBufferEditor::GetOverflow, &CUtlBufferEditor::PutOverflow );
}
コード例 #8
0
ファイル: utlbuffer.cpp プロジェクト: TotallyMehis/ZM-Updated
CUtlBuffer::CUtlBuffer( const void *pBuffer, int nSize, int nFlags ) :
	m_Memory( (unsigned char*)pBuffer, nSize ), m_Error(0)
{
	// FIXMOD_CHANGE - Mehis
	//Assert( nSize != 0 );
	Assert( nSize >= 0 );

	m_bLittleEndian = false;
	m_Get = 0;
	m_Put = 0;
	m_nTab = 0;
	m_nOffset = 0;
	m_Flags = nFlags;
	if ( IsReadOnly() )
	{
		m_nMaxPut = nSize;
	}
	else
	{
		m_nMaxPut = -1;
		AddNullTermination();
	}
	SetOverflowFuncs( &CUtlBuffer::GetOverflow, &CUtlBuffer::PutOverflow );
}