blob: affd5666aea98cac7215af6815a7feaa7e7159f0 (
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//=============================================================================
#ifndef HELPERINFO_H
#define HELPERINFO_H
#pragma once
#include <tier0/dbg.h>
#include <utlvector.h>
#define MAX_HELPER_NAME_LEN 256
typedef CUtlVector<char *> CParameterList;
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CHelperInfo
{
public:
inline CHelperInfo(void);
inline ~CHelperInfo(void);
inline const char *GetName(void) const { return(m_szName); }
inline void SetName(const char *pszName);
inline bool AddParameter(const char *pszParameter);
inline int GetParameterCount(void) const { return(m_Parameters.Count()); }
inline const char *GetParameter(int nIndex) const;
protected:
char m_szName[MAX_HELPER_NAME_LEN];
CParameterList m_Parameters;
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
inline CHelperInfo::CHelperInfo(void)
{
m_szName[0] = '\0';
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
inline CHelperInfo::~CHelperInfo(void)
{
int nCount = m_Parameters.Count();
for (int i = 0; i < nCount; i++)
{
char *pszParam = m_Parameters.Element(i);
Assert(pszParam != NULL);
if (pszParam != NULL)
{
delete [] pszParam;
}
}
m_Parameters.RemoveAll();
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : char *pszParameter -
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
inline bool CHelperInfo::AddParameter(const char *pszParameter)
{
if ((pszParameter != NULL) && (pszParameter[0] != '\0'))
{
int nLen = strlen(pszParameter);
if (nLen > 0)
{
char *pszNew = new char [nLen + 1];
if (pszNew != NULL)
{
strcpy(pszNew, pszParameter);
m_Parameters.AddToTail(pszNew);
return(true);
}
}
}
return(false);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline const char *CHelperInfo::GetParameter(int nIndex) const
{
if (nIndex >= m_Parameters.Count())
return NULL;
return m_Parameters.Element(nIndex);
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : char *pszName -
//-----------------------------------------------------------------------------
inline void CHelperInfo::SetName(const char *pszName)
{
if (pszName != NULL)
{
strcpy(m_szName, pszName);
}
}
typedef CUtlVector<CHelperInfo *> CHelperInfoList;
#endif // HELPERINFO_H
|