*** empty log message ***

svn path=/trunk/; revision=4115
This commit is contained in:
Nedko Arnaudov 2003-02-05 03:18:57 +00:00
parent 325856dad9
commit 3fad983cf2

View file

@ -1,4 +1,4 @@
/* $Id: ArgumentParser.cpp,v 1.6 2001/05/01 20:53:24 narnaoud Exp $
/* $Id: ArgumentParser.cpp,v 1.7 2003/02/05 03:18:57 narnaoud Exp $
*
* regexpl - Console Registry Explorer
*
@ -33,9 +33,9 @@
CArgumentParser::CArgumentParser()
{
m_pchArgumentList = NULL;
m_pchArgumentListEnd = NULL;
m_pchArgument = NULL;
m_pchArgumentList = NULL;
m_pchArgumentListEnd = NULL;
m_pchArgument = NULL;
}
CArgumentParser::~CArgumentParser()
@ -44,68 +44,68 @@ CArgumentParser::~CArgumentParser()
void CArgumentParser::SetArgumentList(TCHAR *pchArguments)
{
TCHAR *pch = m_pchArgumentList = pchArguments;
m_pchArgumentListEnd = pchArguments + _tcslen(pchArguments);
BOOL blnLongArg = FALSE;
while (*pch)
{
switch(*pch)
{
case _T('^'): // argument parser ignores escape sequences
if (pch[1])
pch++;
break;
case _T('\"'):
blnLongArg = !blnLongArg;
break;
case _T(' '):
case _T('\t'):
case _T('\r'):
case _T('\n'):
if (!blnLongArg)
*pch = 0;
break;
}
pch++;
}
ResetArgumentIteration();
TCHAR *pch = m_pchArgumentList = pchArguments;
m_pchArgumentListEnd = pchArguments + _tcslen(pchArguments);
BOOL blnLongArg = FALSE;
while (*pch)
{
switch(*pch)
{
case _T('^'): // argument parser ignores escape sequences
if (pch[1])
pch++;
break;
case _T('\"'):
blnLongArg = !blnLongArg;
break;
case _T(' '):
case _T('\t'):
case _T('\r'):
case _T('\n'):
if (!blnLongArg)
*pch = 0;
break;
}
pch++;
}
ResetArgumentIteration();
}
TCHAR * CArgumentParser::GetNextArgument()
{
ASSERT(m_pchArgumentList); // call SetArgumentList() before calling this function
ASSERT(m_pchArgumentListEnd); // call SetArgumentList() before calling this function
ASSERT(m_pchArgumentListEnd >= m_pchArgumentList);
ASSERT(m_pchArgumentList); // call SetArgumentList() before calling this function
ASSERT(m_pchArgumentListEnd); // call SetArgumentList() before calling this function
ASSERT(m_pchArgumentListEnd >= m_pchArgumentList);
// if this is begin of iteration
if (!m_pchArgument)
m_pchArgument = m_pchArgumentList;
// if this is begin of iteration
if (!m_pchArgument)
m_pchArgument = m_pchArgumentList;
while(m_pchArgument)
{
if (m_pchArgument > m_pchArgumentListEnd)
{ // if end of arguments list reached
ASSERT(m_pchArgument - 1 == m_pchArgumentListEnd);
break;
}
while(m_pchArgument)
{
if (m_pchArgument > m_pchArgumentListEnd)
{ // if end of arguments list reached
ASSERT(m_pchArgument - 1 == m_pchArgumentListEnd);
break;
}
TCHAR *pchArg = m_pchArgument;
TCHAR *pchArg = m_pchArgument;
// Next argument
m_pchArgument += _tcslen(m_pchArgument)+1;
// Next argument
m_pchArgument += _tcslen(m_pchArgument)+1;
if(*pchArg)
{ // if argument is not an empty string
return pchArg;
}
}
if(*pchArg)
{ // if argument is not an empty string
return pchArg;
}
}
return NULL;
return NULL;
}
void CArgumentParser::ResetArgumentIteration()
{
m_pchArgument = NULL;
m_pchArgument = NULL;
}