1 /* $Id: ArgumentParser.cpp,v 1.1 2000/10/04 21:04:30 ea Exp $
3 * regexpl - Console Registry Explorer
5 * Copyright (c) 1999-2000 Nedko Arnaoudov <nedkohome@atia.com>
11 // ArgumentParser.cpp: implementation of the CArgumentParser class.
13 //////////////////////////////////////////////////////////////////////
16 #include "ArgumentParser.h"
18 //////////////////////////////////////////////////////////////////////
19 // Construction/Destruction
20 //////////////////////////////////////////////////////////////////////
22 CArgumentParser::CArgumentParser()
24 m_pchArgumentList
= NULL
;
25 m_pchArgumentListEnd
= NULL
;
29 CArgumentParser::~CArgumentParser()
33 void CArgumentParser::SetArgumentList(TCHAR
*pchArguments
)
35 TCHAR
*pch
= m_pchArgumentList
= pchArguments
;
36 m_pchArgumentListEnd
= pchArguments
+ _tcslen(pchArguments
);
38 BOOL blnLongArg
= FALSE
;
44 if (blnLongArg
) blnLongArg
= FALSE
;
45 else blnLongArg
= TRUE
;
51 if (!blnLongArg
) *pch
= 0;
57 ResetArgumentIteration();
60 TCHAR
* CArgumentParser::GetNextArgument()
62 ASSERT(m_pchArgumentList
); // call SetArgumentList() before calling this function
63 ASSERT(m_pchArgumentListEnd
); // call SetArgumentList() before calling this function
64 ASSERT(m_pchArgumentListEnd
>= m_pchArgumentList
);
66 // if this is begin of iteration
67 if (!m_pchArgument
) m_pchArgument
= m_pchArgumentList
;
71 if (m_pchArgument
> m_pchArgumentListEnd
)
72 { // if end of arguments list reached
73 ASSERT(m_pchArgument
- 1 == m_pchArgumentListEnd
);
77 TCHAR
*pchArg
= m_pchArgument
;
80 m_pchArgument
+= _tcslen(m_pchArgument
)+1;
83 { // if argument is not an empty string
91 void CArgumentParser::ResetArgumentIteration()