iRoCS Toolbox  1.1.0
IStreamIter.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: input stream iterator
26 ** $RCSfile$
27 ** $Revision: 93 $$Name$
28 ** $Date: 2002-10-28 14:11:33 +0100 (Mon, 28 Oct 2002) $
29 ** Copyright: GPL $Author: mechnich $
30 ** Description:
31 **
32 **
33 **
34 **-------------------------------------------------------------------------
35 **
36 ** $Log$
37 ** Revision 1.5 2002/10/28 13:11:33 mechnich
38 ** made everything compile with gcc 3.2
39 ** removed promptUser() from CmdLine.*
40 **
41 ** Revision 1.4 2002/05/14 08:14:15 pigorsch
42 ** - added documentation
43 **
44 ** Revision 1.3 2002/04/10 10:25:51 pigorsch
45 ** - included iostream insead of istream
46 **
47 ** Revision 1.2 2002/04/04 12:03:09 pigorsch
48 ** - renamed operator() to fetch()
49 ** - renamed class CmdIstreamMultiIter to class IStreamIter
50 ** - removed function temporary()
51 **
52 ** Revision 1.1 2002/03/26 07:36:28 ronneber
53 ** restructuring for autoconf
54 **
55 ** Revision 1.1.1.1 2002/03/22 13:45:07 pigorsch
56 ** moved from polsoft repository
57 **
58 **
59 **
60 **************************************************************************/
61 
62 #ifndef ISTREAMITER_HH
63 #define ISTREAMITER_HH
64 
65 #ifdef HAVE_CONFIG_H
66 #include <config.hh>
67 #endif
68 
69 #include <iostream>
70 #include <string>
71 
72 #include "ArgIter.hh"
73 
74 /*======================================================================*/
96 /*======================================================================*/
97 class IStreamIter: public ArgIter
98 {
99 public:
100  /*====================================================================*/
107  /*====================================================================*/
109  std::istream& is,
110  const std::string& separator="---")
111  :pIs(is),
112  pSeparator(separator)
113  {};
114 
115  /*====================================================================*/
123  /*====================================================================*/
124  const char*
126  {
127  pIs >> word;
128  if (!pIs) return 0;
129  if (word==pSeparator) return 0;
130  return word.c_str();
131  };
132 
133 private:
134  std::istream& pIs;
135  std::string word;
136  std::string pSeparator;
137 };
138 
139 #endif
IStreamIter(std::istream &is, const std::string &separator="---")
Constructor.
Definition: IStreamIter.hh:108
const char * fetch()
Returns the current argument, advances to the next argument and returns NULL is there are no argument...
Definition: IStreamIter.hh:125
The IStreamIter class fetches arguments from an input stream.
Definition: IStreamIter.hh:97
The ArgIter class is an abstract class used by the CmdLine class for fetching command line arguments...
Definition: ArgIter.hh:73