1 /* $Id: ArgumentParser.cpp,v 1.4 2001/01/13 23:53:46 narnaoud Exp $
3 * regexpl - Console Registry Explorer
5 * Copyright (C) 2000,2001 Nedko Arnaoudov <nedkohome@atia.com>
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
;
56 blnLongArg
= !blnLongArg
;
69 ResetArgumentIteration();
72 TCHAR
* CArgumentParser::GetNextArgument()
74 ASSERT(m_pchArgumentList
); // call SetArgumentList() before calling this function
75 ASSERT(m_pchArgumentListEnd
); // call SetArgumentList() before calling this function
76 ASSERT(m_pchArgumentListEnd
>= m_pchArgumentList
);
78 // if this is begin of iteration
80 m_pchArgument
= m_pchArgumentList
;
84 if (m_pchArgument
> m_pchArgumentListEnd
)
85 { // if end of arguments list reached
86 ASSERT(m_pchArgument
- 1 == m_pchArgumentListEnd
);
90 TCHAR
*pchArg
= m_pchArgument
;
93 m_pchArgument
+= _tcslen(m_pchArgument
)+1;
96 { // if argument is not an empty string
104 void CArgumentParser::ResetArgumentIteration()
106 m_pchArgument
= NULL
;