iRoCS Toolbox  1.1.0
ArgvIter.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2005-2015 Olaf Ronneberger, Jörg Mechnich, Florian Pigorsch,
4  * Mario Emmenlauer, Thorsten Schmidt
5  *
6  * Image Analysis Lab, University of Freiburg, Germany
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  **************************************************************************/
23 
24 /**************************************************************************
25 ** Title: command line arguments iterator
26 ** $RCSfile$
27 ** $Revision: 78 $$Name$
28 ** $Date: 2002-05-14 10:14:15 +0200 (Tue, 14 May 2002) $
29 ** Copyright: GPL $Author: pigorsch $
30 ** Description:
31 **
32 **
33 **
34 **-------------------------------------------------------------------------
35 **
36 ** $Log$
37 ** Revision 1.3 2002/05/14 08:13:56 pigorsch
38 ** - added documentation
39 **
40 ** Revision 1.2 2002/04/04 12:02:49 pigorsch
41 ** - renamed operator() to fetch()
42 ** - removed function temporary()
43 **
44 ** Revision 1.1 2002/03/26 07:36:28 ronneber
45 ** restructuring for autoconf
46 **
47 ** Revision 1.1.1.1 2002/03/22 13:45:07 pigorsch
48 ** moved from polsoft repository
49 **
50 **
51 **
52 **************************************************************************/
53 
54 #ifndef ARGVITER_HH
55 #define ARGVITER_HH
56 
57 #ifdef HAVE_CONFIG_H
58 #include <config.hh>
59 #endif
60 
61 #include "ArgIter.hh"
62 
63 /*======================================================================*/
85 /*======================================================================*/
86 class ArgvIter: public ArgIter
87 {
88 public:
89  /*====================================================================*/
96  /*====================================================================*/
98  int argc,
99  const char* const* argv)
100  :pCount(argc),
101  pIndex(0),
102  pArray(argv)
103  {};
104 
105  /*====================================================================*/
112  /*====================================================================*/
113  const char*
115  {
116  const char* s=0;
117 
118  if (pIndex<pCount && pArray[pIndex]!=0)
119  {
120  s=pArray[pIndex];
121  ++pIndex;
122  }
123 
124  return s;
125  };
126 
127  /*====================================================================*/
134  /*====================================================================*/
135  void
137  int argc,
138  const char* const* argv)
139  {
140  pCount=argc;
141  pArray=argv;
142  pIndex=0;
143  };
144 
145 private:
146  int pCount;
147  int pIndex;
148  const char* const* pArray;
149 };
150 
151 #endif
void reset(int argc, const char *const *argv)
Specify new array of strings to be parsed.
Definition: ArgvIter.hh:136
const char * fetch()
Returns the current argument, advances to the next argument and returns NULL is there are no argument...
Definition: ArgvIter.hh:114
ArgvIter(int argc, const char *const *argv)
Constructor.
Definition: ArgvIter.hh:97
The ArgvIter class fetches arguments from a c-style char* array.
Definition: ArgvIter.hh:86
The ArgIter class is an abstract class used by the CmdLine class for fetching command line arguments...
Definition: ArgIter.hh:73