antioch-0.4.0
parser_base.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // Antioch - A Gas Dynamics Thermochemistry Library
5 //
6 // Copyright (C) 2014-2016 Paul T. Bauman, Benjamin S. Kirk,
7 // Sylvain Plessis, Roy H. Stonger
8 //
9 // Copyright (C) 2013 The PECOS Development Team
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the Version 2.1 GNU Lesser General
13 // Public License as published by the Free Software Foundation.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
23 // Boston, MA 02110-1301 USA
24 //
25 //-----------------------------------------------------------------------el-
26 
27 // This class
28 #include "antioch/parser_base.h"
29 
30 // Antioch
32 
33 namespace Antioch
34 {
35  template <typename NumericType>
36  ParserBase<NumericType>::ParserBase(const std::string & type, const std::string & file, bool verbose, const std::string & comments)
37  : _type(type),
38  _file(file),
39  _verbose(verbose),
40  _comments(comments)
41  {
42  std::stringstream os;
43  os << "\n*********************************************************\n"
44  << "This method is not available with a " << _type << " parser.\n"
45  << "Parsing file " << _file << ".\n"
46  << "No format has been defined yet. Maybe contribute?\n"
47  << "https://github.com/libantioch/antioch\n"
48  << "\n\n*********************************************************\n\n";
49 
50  _not_implemented = os.str();
51  }
52 
53  template <typename NumericType>
54  void ParserBase<NumericType>::skip_comments(std::istream & doc)
55  {
56  for(unsigned int c = 0; c < _comments.size(); c++)
57  {
58  skip_comment_lines(doc, _comments[c]);
59  }
60  }
61 
62  template <typename NumericType>
64  {
65  ParsingType PType(ASCII);
66  if(_type == "ascii")
67  {
68  PType = ASCII;
69  }
70  else if(_type == "ChemKin")
71  {
72  PType = CHEMKIN;
73  }
74  else if(_type == "XML")
75  {
76  PType = XML;
77  }
78  else
79  {
80  antioch_parsing_error(std::string("unknown parser type!!! " + _type));
81  }
82 
83  return PType;
84  }
85 
86 } // end namespace Antioch
87 
88 // Instantiate
ParsingType enum_type() const
Definition: parser_base.C:63
void skip_comments(std::istream &doc)
Definition: parser_base.C:54
std::string _type
Definition: parser_base.h:258
#define antioch_parsing_error(description)
The parameters are reduced parameters.
void skip_comment_lines(std::istream &in, const char comment_start)
Skip comment lines in the header of an ASCII text file prefixed with the comment character 'comment_s...
Definition: input_utils.h:46
ANTIOCH_NUMERIC_TYPE_CLASS_INSTANTIATE(Antioch::ParserBase)
std::string _file
Definition: parser_base.h:259
std::string _not_implemented
Definition: parser_base.h:263
A parser is an instance related to a file.

Generated on Thu Jul 7 2016 11:09:45 for antioch-0.4.0 by  doxygen 1.8.8