2 * regexpl - Console Registry Explorer
4 * Copyright (C) 2000-2005 Nedko Arnaudov <nedko@users.sourceforge.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 // ArgumentParser.cpp: implementation of the CArgumentParser class.
24 //////////////////////////////////////////////////////////////////////
27 #include "ArgumentParser.h"
29 //////////////////////////////////////////////////////////////////////
30 // Construction/Destruction
31 //////////////////////////////////////////////////////////////////////
33 CArgumentParser::CArgumentParser()
35 m_pchArgumentList
= NULL
;
36 m_pchArgumentListEnd
= NULL
;
40 CArgumentParser::~CArgumentParser()
44 void CArgumentParser::SetArgumentList(TCHAR
*pchArguments
)
46 TCHAR
*pch
= m_pchArgumentList
= pchArguments
;
47 m_pchArgumentListEnd
= pchArguments
+ _tcslen(pchArguments
);
49 BOOL blnLongArg
= FALSE
;
54 case _T('^'): // argument parser ignores escape sequences
59 blnLongArg
= !blnLongArg
;
72 ResetArgumentIteration();
75 TCHAR
* CArgumentParser::GetNextArgument()
77 ASSERT(m_pchArgumentList
); // call SetArgumentList() before calling this function
78 ASSERT(m_pchArgumentListEnd
); // call SetArgumentList() before calling this function
79 ASSERT(m_pchArgumentListEnd
>= m_pchArgumentList
);
81 // if this is begin of iteration
83 m_pchArgument
= m_pchArgumentList
;
87 if (m_pchArgument
> m_pchArgumentListEnd
)
88 { // if end of arguments list reached
89 ASSERT(m_pchArgument
- 1 == m_pchArgumentListEnd
);
93 TCHAR
*pchArg
= m_pchArgument
;
96 m_pchArgument
+= _tcslen(m_pchArgument
)+1;
99 { // if argument is not an empty string
107 void CArgumentParser::ResetArgumentIteration()
109 m_pchArgument
= NULL
;