blob: 664dcd7440552b5e3a6e3018c0ef67bb329124cc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
|