summaryrefslogtreecommitdiffstats
path: root/CCommandLine.cpp
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2013-03-18 15:27:26 +0100
committermanuel <manuel@mausz.at>2013-03-18 15:27:26 +0100
commit8c417384e29635c680745425abd630d5208cbaf2 (patch)
tree107f4824bb697fdef08cc30fea532159eca4171d /CCommandLine.cpp
parent7dd1948c98c3cf10fe142384f9756e197d9f5bff (diff)
downloadsteamcmd-8c417384e29635c680745425abd630d5208cbaf2.tar.gz
steamcmd-8c417384e29635c680745425abd630d5208cbaf2.tar.bz2
steamcmd-8c417384e29635c680745425abd630d5208cbaf2.zip
replace mod-param with generic "-config key=val"-param
Diffstat (limited to 'CCommandLine.cpp')
-rw-r--r--CCommandLine.cpp38
1 files changed, 32 insertions, 6 deletions
diff --git a/CCommandLine.cpp b/CCommandLine.cpp
index 3df07b1..afb115d 100644
--- a/CCommandLine.cpp
+++ b/CCommandLine.cpp
@@ -31,18 +31,28 @@ void CCommandLine::AddParm(const char *psz)
31 m_argc++; 31 m_argc++;
32} 32}
33 33
34const char* CCommandLine::ParmValue(const char *psz, const char *pDefaultVal) const 34const char* CCommandLine::ParmValues(const char *psz, unsigned int ix) const
35{ 35{
36 int nIndex = FindParm(psz); 36 int nIndex = FindParm(psz, ix);
37 if((nIndex == 0) || (nIndex == m_argc - 1)) 37 if((nIndex == 0) || (nIndex == m_argc - 1))
38 return pDefaultVal; 38 return NULL;
39 39
40 if(m_argv[nIndex + 1][0] == '-' || m_argv[nIndex + 1][0] == '+') 40 if(m_argv[nIndex + 1][0] == '-' || m_argv[nIndex + 1][0] == '+')
41 return pDefaultVal; 41 return NULL;
42 42
43 return m_argv[nIndex + 1]; 43 return m_argv[nIndex + 1];
44} 44}
45 45
46const char* CCommandLine::ParmValue(const char *psz, const char *pDefaultVal) const
47{
48 const char* cszValue = ParmValues(psz, 0);
49
50 if(!cszValue)
51 return pDefaultVal;
52
53 return cszValue;
54}
55
46int CCommandLine::ParmValue(const char *psz, int nDefaultVal) const 56int CCommandLine::ParmValue(const char *psz, int nDefaultVal) const
47{ 57{
48 const char* cszValue = ParmValue(psz); 58 const char* cszValue = ParmValue(psz);
@@ -58,12 +68,28 @@ unsigned int CCommandLine::ParmCount() const
58 return m_argc; 68 return m_argc;
59} 69}
60 70
61unsigned int CCommandLine::FindParm(const char *psz) const 71unsigned int CCommandLine::FindParmCount(const char *psz) const
72{
73 unsigned cnt = 0;
74 for(int i = 1; i < m_argc; i++)
75 {
76 if(strcmp(m_argv[i], psz) == 0)
77 cnt++;
78 }
79
80 return cnt;
81}
82
83unsigned int CCommandLine::FindParm(const char *psz, unsigned int ix) const
62{ 84{
63 for(int i = 1; i < m_argc; i++) 85 for(int i = 1; i < m_argc; i++)
64 { 86 {
65 if(strcmp(m_argv[i], psz) == 0) 87 if(strcmp(m_argv[i], psz) == 0)
66 return i; 88 {
89 if (ix == 0)
90 return i;
91 ix--;
92 }
67 } 93 }
68 94
69 return 0; 95 return 0;