コード例 #1
0
//-----------------------------------------------------------------------------
// Purpose: Append parameter and argument values to command line
// Input  : *pszParm - 
//			*pszValues - 
//-----------------------------------------------------------------------------
void CCommandLine::AppendParm( const char *pszParm, const char *pszValues )
{
	int nNewLength = 0;
	char *pCmdString;

	nNewLength = strlen( pszParm );            // Parameter.
	if ( pszValues )
		nNewLength += strlen( pszValues ) + 1;  // Values + leading space character.
	nNewLength++; // Terminal 0;

	if ( !m_pszCmdLine )
	{
		m_pszCmdLine = new char[ nNewLength ];
		strcpy( m_pszCmdLine, pszParm );
		if ( pszValues )
		{
			strcat( m_pszCmdLine, " " );
			strcat( m_pszCmdLine, pszValues );
		}

		ParseCommandLine();
		return;
	}

	// Remove any remnants from the current Cmd Line.
	RemoveParm( pszParm );

	nNewLength += strlen( m_pszCmdLine ) + 1 + 1;

	pCmdString = new char[ nNewLength ];
	memset( pCmdString, 0, nNewLength );

	strcpy ( pCmdString, m_pszCmdLine ); // Copy old command line.
	strcat ( pCmdString, " " ); // Put in a space
	strcat ( pCmdString, pszParm );
	if ( pszValues )
	{
		strcat( pCmdString, " " );
		strcat( pCmdString, pszValues );
	}

	// Kill off the old one
	delete[] m_pszCmdLine;

	// Point at the new command line.
	m_pszCmdLine = pCmdString;

	ParseCommandLine();
}
コード例 #2
0
void CCommandLine::AppendParm(const char *pszParm, const char *pszValues)
{
	int nNewLength = 0;
	char *pCmdString;

	nNewLength = strlen(pszParm);

	if (pszValues)
		nNewLength += strlen(pszValues) + 1;

	if (!m_pszCmdLine)
	{
		m_pszCmdLine = new char [nNewLength];
		strcpy(m_pszCmdLine, pszParm);

		if (pszValues)
		{
			strcat(m_pszCmdLine, " ");
			strcat(m_pszCmdLine, pszValues);
		}

		return;
	}

	RemoveParm(pszParm);

	nNewLength += strlen(m_pszCmdLine) + 1 + 1;
	pCmdString = new char [nNewLength];
	memset(pCmdString, 0, nNewLength);

	strcpy(pCmdString, m_pszCmdLine);
	strcat(pCmdString, " ");
	strcat(pCmdString, pszParm);

	if (pszValues)
	{
		strcat(pCmdString, " ");
		strcat(pCmdString, pszValues);
	}

	delete [] m_pszCmdLine;
	m_pszCmdLine = pCmdString;
}
コード例 #3
0
void CCommandLine::SetParm(const char *pszParm, const char *pszValues)
{
	RemoveParm(pszParm);
	AppendParm(pszParm, pszValues);
}