0c96eadcbd56ff99f75737007197c34cf0d0f625
3 * regexpl - Console Registry Explorer
5 * Copyright (C) 2000-2005 Nedko Arnaudov <nedko@users.sourceforge.net>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 // ArgumentParser.cpp: implementation of the CArgumentParser class.
25 //////////////////////////////////////////////////////////////////////
28 #include "ArgumentParser.h"
30 //////////////////////////////////////////////////////////////////////
31 // Construction/Destruction
32 //////////////////////////////////////////////////////////////////////
34 CArgumentParser::CArgumentParser()
36 m_pchArgumentList
= NULL
;
37 m_pchArgumentListEnd
= NULL
;
41 CArgumentParser::~CArgumentParser()
45 void CArgumentParser::SetArgumentList(TCHAR
*pchArguments
)
47 TCHAR
*pch
= m_pchArgumentList
= pchArguments
;
48 m_pchArgumentListEnd
= pchArguments
+ _tcslen(pchArguments
);
50 BOOL blnLongArg
= FALSE
;
55 case _T('^'): // argument parser ignores escape sequences
60 blnLongArg
= !blnLongArg
;
73 ResetArgumentIteration();
76 TCHAR
* CArgumentParser::GetNextArgument()
78 ASSERT(m_pchArgumentList
); // call SetArgumentList() before calling this function
79 ASSERT(m_pchArgumentListEnd
); // call SetArgumentList() before calling this function
80 ASSERT(m_pchArgumentListEnd
>= m_pchArgumentList
);
82 // if this is begin of iteration
84 m_pchArgument
= m_pchArgumentList
;
88 if (m_pchArgument
> m_pchArgumentListEnd
)
89 { // if end of arguments list reached
90 ASSERT(m_pchArgument
- 1 == m_pchArgumentListEnd
);
94 TCHAR
*pchArg
= m_pchArgument
;
97 m_pchArgument
+= _tcslen(m_pchArgument
)+1;
100 { // if argument is not an empty string
108 void CArgumentParser::ResetArgumentIteration()
110 m_pchArgument
= NULL
;