queso-0.53.0
StreamUtilities.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2015 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library 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 GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 // This class
26 #include <queso/asserts.h>
27 #include <queso/StreamUtilities.h>
28 
29 // C++
30 #include <istream>
31 #include <locale> // isspace
32 
33 namespace QUESO
34 {
35  void StreamUtilities::skip_comment_lines( std::istream &in,
36  const char comment_start)
37  {
38  char c, line[256];
39 
40  in.get(c);
41  // std::isspace used to be std::isblank, but the latter requires C++11
42  // There are slight differences, but for our purposes, this should
43  // be OK.
44  while(std::isspace(c))in.get(c);
45 
46  in.putback(c);
47  queso_require( !in.fail() );
48 
49  while (in.get(c), c==comment_start)
50  in.getline (line, 255);
51 
52  // put back first character of
53  // first non-comment line
54  in.putback (c);
55  queso_require( !in.fail() );
56 
57  }
58 
59 } // end namespace QUESO
static void skip_comment_lines(std::istream &in, const char comment_start)
Skips comment lines until a line without a comment character is encountered.
#define queso_require(asserted)
Definition: asserts.h:124

Generated on Thu Jun 11 2015 13:52:32 for queso-0.53.0 by  doxygen 1.8.5