diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/shared/cstrike/bot/shared_util.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/shared/cstrike/bot/shared_util.h')
| -rw-r--r-- | game/shared/cstrike/bot/shared_util.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/game/shared/cstrike/bot/shared_util.h b/game/shared/cstrike/bot/shared_util.h new file mode 100644 index 0000000..664dcd7 --- /dev/null +++ b/game/shared/cstrike/bot/shared_util.h @@ -0,0 +1,83 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: dll-agnostic routines (no dll dependencies here) +// +// $NoKeywords: $ +//=============================================================================// + +// Author: Matthew D. Campbell ([email protected]), 2003 + +#ifndef SHARED_UTIL_H +#define SHARED_UTIL_H + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +//-------------------------------------------------------------------------------------------------------- +/** + * Returns the token parsed by SharedParse() + */ +char *SharedGetToken( void ); + +//-------------------------------------------------------------------------------------------------------- +/** + * Sets the character used to delimit quoted strings. Default is '\"'. Be sure to set it back when done. + */ +void SharedSetQuoteChar( char c ); + +//-------------------------------------------------------------------------------------------------------- +/** + * Parse a token out of a string + */ +const char *SharedParse( const char *data ); + +//-------------------------------------------------------------------------------------------------------- +/** + * Returns true if additional data is waiting to be processed on this line + */ +bool SharedTokenWaiting( const char *buffer ); + +//-------------------------------------------------------------------------------------------------------- +/** + * Simple utility function to allocate memory and duplicate a string + */ +inline char *CloneString( const char *str ) +{ + char *cloneStr = new char [ strlen(str)+1 ]; + strcpy( cloneStr, str ); + return cloneStr; +} + +//-------------------------------------------------------------------------------------------------------------- +/** + * snprintf-alike that allows multiple prints into a buffer + */ +char * BufPrintf(char *buf, int& len, PRINTF_FORMAT_STRING const char *fmt, ...); + +//-------------------------------------------------------------------------------------------------------------- +/** + * wide char version of BufPrintf + */ +wchar_t * BufWPrintf(wchar_t *buf, int& len, PRINTF_FORMAT_STRING const wchar_t *fmt, ...); + +//-------------------------------------------------------------------------------------------------------------- +/** + * convenience function that prints an int into a static wchar_t* + */ +const wchar_t * NumAsWString( int val ); + +//-------------------------------------------------------------------------------------------------------------- +/** + * convenience function that prints an int into a static char* + */ +const char * NumAsString( int val ); + +//-------------------------------------------------------------------------------------------------------------- +/** + * convenience function that composes a string into a static char* + */ +char * SharedVarArgs(PRINTF_FORMAT_STRING const char *format, ...); + +#include "tier0/memdbgoff.h" + +#endif // SHARED_UTIL_H |