Ejemplo n.º 1
0
 void pff_footer::print()
 {
   int ip = GetIP();
   cout << "IP:          " << (int)((unsigned char*)(&ip))[0] << "." << (int)((unsigned char*)(&ip))[1] << "." << (int)((unsigned char*)(&ip))[2] << "." << (int)((unsigned char*)(&ip))[3] <<endl;
   cout << "RESERVED:    " << GetReserved() << endl;
   cout << "KING TAG:    " << GetKingTag()[0] << GetKingTag()[1] << GetKingTag()[2] << GetKingTag()[3] << endl;
 }
Ejemplo n.º 2
0
// Append
//------------------------------------------------------------------------------
void AString::Append( const char * string, size_t len )
{
	uint32_t newLen = m_Length + (uint32_t)len;
	if ( newLen > GetReserved() )
	{
		Grow( newLen );
	}

	Copy( string, m_Contents + m_Length, len ); // handles terminator
	m_Length = newLen;
}
Ejemplo n.º 3
0
bool BEParser::Parse_Export_Animation(BEAnimationList *pAnimationList)
{
	pScanner->ReadToken();
	RTOKENTYPE tt=pScanner->GetTokenType();
	if(tt==RTOKEN_SEMICOLON) { return true; }
	if(tt!=RTOKEN_STRING) { return false; }
	if(GetReserved(pScanner->GetToken())!=IANIMATION) return false;

	pScanner->ReadToken();
	AnimationParam *newani=new AnimationParam;
	reservedcode rc=GetReserved(pScanner->GetToken());
	switch(rc)
	{
		case ITRANSFORM	: newani->iAnimationType=AM_TRANSFORM;break;
		case IVERTEX	: newani->iAnimationType=AM_VERTEX;break;
		case IKEYFRAME	: newani->iAnimationType=AM_KEYFRAME;break;
		default : delete newani;return false;
	}
		
	pScanner->ReadToken();
	tt=pScanner->GetTokenType();
	if((tt!=RTOKEN_STRING)&&(tt!=RTOKEN_CONSTANTSTRING)) return false;
	pScanner->GetToken(newani->szAnimationName,sizeof(newani->szAnimationName));
	
	pScanner->ReadToken();
	tt=pScanner->GetTokenType();
	switch(tt)
	{
		case RTOKEN_NUMBER : {int i;pScanner->GetToken(&i);newani->fAnimationSpeed=(float)i;}break;
		case RTOKEN_REALNUMBER : { float f;pScanner->GetToken(&f);newani->fAnimationSpeed=f;}break;
		default : delete newani;return false;
	}

	pScanner->ReadToken();
	tt=pScanner->GetTokenType();
	if((tt!=RTOKEN_STRING)&&(tt!=RTOKEN_CONSTANTSTRING)) return false;
	pScanner->GetToken(newani->szMaxFileName,sizeof(newani->szMaxFileName));

	pAnimationList->Add(newani);
	return Parse_Export_Animation(pAnimationList);
}
Ejemplo n.º 4
0
// operator += (char)
//------------------------------------------------------------------------------
AString & AString::operator += ( char c )
{
	// need more space?
	if ( m_Length >= GetReserved() )
	{
		Grow( m_Length + 1 );
	}
	m_Contents[ m_Length++ ] = c;
	m_Contents[ m_Length ] = '\000';

	return *this;
}
Ejemplo n.º 5
0
// operator += ( const AString & )
//------------------------------------------------------------------------------
AString & AString::operator += ( const AString & string )
{
	uint32_t suffixLen = string.GetLength();
	uint32_t newLen = m_Length + suffixLen;
	if ( newLen > GetReserved() )
	{
		Grow( newLen );
	}

	Copy( string.Get(), m_Contents + m_Length, suffixLen ); // handles terminator
	m_Length += suffixLen;

	return *this;
}
Ejemplo n.º 6
0
// operator += (const char *)
//------------------------------------------------------------------------------
AString & AString::operator += ( const char * string )
{
	uint32_t suffixLen = (uint32_t)StrLen( string );
	if ( suffixLen )
	{
		uint32_t newLen = m_Length + suffixLen;
		if ( newLen > GetReserved() )
		{
			Grow( newLen );
		}

		Copy( string, m_Contents + m_Length, suffixLen ); // handles terminator
		m_Length += suffixLen;
	}
	return *this;
}
Ejemplo n.º 7
0
// Assign (const AString &)
//------------------------------------------------------------------------------
void AString::Assign( const AString & string )
{
	uint32_t len = string.GetLength();
	if ( len > GetReserved() )
	{
		GrowNoCopy( len );
	}
	else if ( m_Contents == s_EmptyString )
	{
		// if we are the special empty string, and we
		// didn't resize then the passed in string is empty too
		return;
	}
	Copy( string.Get(), m_Contents, len ); // handles terminator
	m_Length = len;
}
Ejemplo n.º 8
0
// Assign (const char *, const char *)
//------------------------------------------------------------------------------
void AString::Assign( const char * start, const char * end )
{
	ASSERT( start <= end );
	uint32_t len = uint32_t( end - start );
	if ( len > GetReserved() )
	{
		GrowNoCopy( len );
	}
	else if ( m_Contents == s_EmptyString )
	{
		// if we are the special empty string, and we
		// didn't resize then the passed in string is empty too
		return;
	}
	Copy( start, m_Contents, len ); // handles terminator
	m_Length = len;
}
Ejemplo n.º 9
0
// Grow
//------------------------------------------------------------------------------
void AString::Grow( uint32_t newLength )
{
	// allocate space, rounded up to multiple of 2
	const uint32_t amortizedReserve = ( GetReserved() * 2 );
	const uint32_t reserve = Math::RoundUp( Math::Max( amortizedReserve, newLength ),(uint32_t)2 );
	char * newMem = (char *)ALLOC( reserve + 1 ); // also allocate for \0 terminator

	// transfer existing string data
	Copy( m_Contents, newMem, m_Length );

	if ( MemoryMustBeFreed() )
	{
		FREE( m_Contents );
	}

	m_Contents = newMem;
	SetReserved( reserve, true );
}
Ejemplo n.º 10
0
// SetLength
//------------------------------------------------------------------------------
void AString::SetLength( uint32_t len )
{
	if ( len > GetReserved() )
	{
		Grow( len );
	}

	// Gracefully handle SetLength( 0 ) on already empty string pointing to the
	// global storage.
	if ( m_Contents != s_EmptyString )
	{
		m_Contents[ len ] = '\000';
	}
	m_Length = len;

	// NOTE: it's up to the user to ensure everything upto the null is
	// valid
}
Ejemplo n.º 11
0
bool BEParser::Open(const char *filename)
{
	FILE *file;
	file=fopen(filename,"r");
	if(!file) return false;

	pScanner=new RSScanner;
	pScanner->Open(file);

	while(pScanner->GetTokenType()!=RTOKEN_NULL)
	{
		reservedcode rc=GetReserved(pScanner->GetToken());

		bool bReturn=0;
		switch ( rc )
		{
		case IRMLFILE		: bReturn=Parse_RmlFile();break;
		case ISOURCE		: bReturn=Parse_Source();break;
		case IDESTINATION	: bReturn=Parse_Destination();break;
		case IEXPORT		: bReturn=Parse_Export();break;
		default: goto ERROR_OCCURED;
		}
		if(!bReturn) goto ERROR_OCCURED;
		pScanner->ReadToken();
	}

	fclose(file);
	return true;

ERROR_OCCURED:
	sprintf(errormessage,"parse error line number %d",pScanner->GetCurrentLineNumber());
	delete pScanner;
	pScanner=NULL;
	fclose(file);
	return false;
}