ReactOS 0.4.15-dev-7897-g78dc504
ArgumentParser.cpp
Go to the documentation of this file.
1/*
2 * regexpl - Console Registry Explorer
3 *
4 * Copyright (C) 2000-2005 Nedko Arnaudov <nedko@users.sourceforge.net>
5 *
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.
10 *
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.
15 *
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.
20 */
21
22// ArgumentParser.cpp: implementation of the CArgumentParser class.
23//
25
26#include "ph.h"
27#include "ArgumentParser.h"
28
30// Construction/Destruction
32
34{
38}
39
41{
42}
43
45{
46 TCHAR *pch = m_pchArgumentList = pchArguments;
47 m_pchArgumentListEnd = pchArguments + _tcslen(pchArguments);
48
49 BOOL blnLongArg = FALSE;
50 while (*pch)
51 {
52 switch(*pch)
53 {
54 case _T('^'): // argument parser ignores escape sequences
55 if (pch[1])
56 pch++;
57 break;
58 case _T('\"'):
59 blnLongArg = !blnLongArg;
60 break;
61 case _T(' '):
62 case _T('\t'):
63 case _T('\r'):
64 case _T('\n'):
65 if (!blnLongArg)
66 *pch = 0;
67 break;
68 }
69 pch++;
70 }
71
73}
74
76{
77 ASSERT(m_pchArgumentList); // call SetArgumentList() before calling this function
78 ASSERT(m_pchArgumentListEnd); // call SetArgumentList() before calling this function
80
81 // if this is begin of iteration
82 if (!m_pchArgument)
84
85 while(m_pchArgument)
86 {
88 { // if end of arguments list reached
90 break;
91 }
92
93 TCHAR *pchArg = m_pchArgument;
94
95 // Next argument
97
98 if(*pchArg)
99 { // if argument is not an empty string
100 return pchArg;
101 }
102 }
103
104 return NULL;
105}
106
108{
110}
virtual ~CArgumentParser()
void SetArgumentList(TCHAR *pchArguments)
TCHAR * m_pchArgument
const TCHAR * m_pchArgumentListEnd
void ResetArgumentIteration()
TCHAR * GetNextArgument()
TCHAR * m_pchArgumentList
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define pch(ap)
Definition: match.c:418
#define ASSERT(a)
Definition: mode.c:44
#define _T(x)
Definition: vfdio.h:22
char TCHAR
Definition: xmlstorage.h:189
#define _tcslen
Definition: xmlstorage.h:198