r5sdk/r5dev/tier0/commandline.cpp

139 lines
4.7 KiB
C++
Raw Normal View History

2022-01-10 01:20:44 +01:00
//=============================================================================//
//
// Purpose: Command line utilities
//
//=============================================================================//
#include "core/stdafx.h"
#include "tier0/commandline.h"
#include "tier1/cvar.h"
2022-01-10 01:20:44 +01:00
//-----------------------------------------------------------------------------
// Purpose: Create a command line from the passed in string
// Note that if you pass in a @filename, then the routine will read settings
// from a file instead of the command line
2022-01-10 01:20:44 +01:00
//-----------------------------------------------------------------------------
void CCommandLine::CreateCmdLine(const char* pszCommandline)
{
static int index = 0;
CallVFunc<void>(index, this, pszCommandline);
2022-01-10 01:20:44 +01:00
}
//-----------------------------------------------------------------------------
// Purpose: creates a command line from the arguments passed in
2022-01-10 01:20:44 +01:00
//-----------------------------------------------------------------------------
void CCommandLine::CreateCmdLine(int argc, char** argv)
{
static int index = 1;
CallVFunc<void>(index, this, argc, argv);
2022-01-10 01:20:44 +01:00
}
//-----------------------------------------------------------------------------
// Purpose: allocates a pool for the command line [seems unused]
2022-01-10 01:20:44 +01:00
//-----------------------------------------------------------------------------
void CCommandLine::CreatePool(void* pMem)
{
static int index = 2;
CallVFunc<void>(index, this, pMem);
2022-01-10 01:20:44 +01:00
}
//-----------------------------------------------------------------------------
// Purpose: Return current command line
// Output : const char
//-----------------------------------------------------------------------------
const char* CCommandLine::GetCmdLine(void)
{
static int index = 3;
return CallVFunc<const char*>(index, this);
2022-01-10 01:20:44 +01:00
}
//-----------------------------------------------------------------------------
// Purpose: Search for the parameter in the current commandline
// Input : *psz -
// **ppszValue -
// Output : char
//-----------------------------------------------------------------------------
const char* CCommandLine::CheckParm(const char* psz, const char** ppszValue)
{
static int index = 4;
return CallVFunc<const char*>(index, this, psz, ppszValue);
2022-01-10 01:20:44 +01:00
}
//-----------------------------------------------------------------------------
// Purpose: Remove specified string ( and any args attached to it ) from command line
// Input : *pszParm -
//-----------------------------------------------------------------------------
void CCommandLine::RemoveParm(const char* pszParm)
2022-01-10 01:20:44 +01:00
{
static int index = 5;
CallVFunc<void>(index, this, pszParm);
2022-01-10 01:20:44 +01:00
}
//-----------------------------------------------------------------------------
// Purpose: Append parameter and argument values to command line
// Input : *pszParm -
// *pszValues -
//-----------------------------------------------------------------------------
void CCommandLine::AppendParm(const char* pszParm, const char* pszValues)
{
static int index = 6;
CallVFunc<void>(index, this, pszParm, pszValues);
2022-01-10 01:20:44 +01:00
}
//-----------------------------------------------------------------------------
2022-02-13 15:16:09 +01:00
// Purpose: returns the argument after the one specified, or the default if not found
2022-01-10 01:20:44 +01:00
//-----------------------------------------------------------------------------
const char* CCommandLine::ParmValue(const char* psz, const char* pDefaultVal)
{
static int index = 7;
return CallVFunc<const char*>(index, this, psz, pDefaultVal);
2022-01-10 01:20:44 +01:00
}
int CCommandLine::ParmValue(const char* psz, int nDefaultVal)
{
static int index = 8;
return CallVFunc<int>(index, this, psz, nDefaultVal);
2022-01-10 01:20:44 +01:00
}
float CCommandLine::ParmValue(const char* psz, float flDefaultVal)
{
static int index = 9;
return CallVFunc<float>(index, this, psz, flDefaultVal);
2022-01-10 01:20:44 +01:00
}
//-----------------------------------------------------------------------------
// Purpose: returns individual command line arguments
2022-01-10 01:20:44 +01:00
//-----------------------------------------------------------------------------
int CCommandLine::ParmCount(void)
{
static int index = 10;
return CallVFunc<int>(index, this);
2022-01-10 01:20:44 +01:00
}
int CCommandLine::FindParm(const char* psz)
{
static int index = 11;
return CallVFunc<int>(index, this, psz);
2022-01-10 01:20:44 +01:00
}
const char* CCommandLine::GetParm(int nIndex)
{
static int index = 12;
return CallVFunc<const char*>(index, this, nIndex);
2022-01-10 01:20:44 +01:00
}
void CCommandLine::SetParm(int nIndex, char const* pParm)
{
static int index = 14;
CallVFunc<void>(index, this, nIndex, pParm);
2022-01-10 01:20:44 +01:00
}
///////////////////////////////////////////////////////////////////////////////
CCommandLine* g_pCmdLine = nullptr;
//-----------------------------------------------------------------------------
// Instance singleton and expose interface to rest of code
//-----------------------------------------------------------------------------
CCommandLine* CommandLine(void)
{
return g_pCmdLine;
}