Parses an input file and extracts parameters. More...

#include <inputOutput.hh>

Inheritance diagram for concepts::InputParser:
concepts::OutputOperator

Public Types

typedef struct yy_buffer_state * YY_BUFFER_STATE
 The buffer representing the input file (for the parser) More...
 

Public Member Functions

InOutParametersinputParameters ()
 Returns the input data. More...
 
 InputParser (bool quiet=false)
 Default constructor. More...
 
InOutParametersoutputParameters ()
 Returns the output data. More...
 
void parse ()
 Parses the input file. More...
 
void parse (std::string file)
 Parses the input file. More...
 
virtual ~InputParser ()
 

Protected Member Functions

virtual std::ostream & info (std::ostream &os) const
 Returns information in an output stream. More...
 

Private Attributes

YY_BUFFER_STATE current_buffer_
 The current input buffer (for the parser) More...
 
InOutParameters input_
 Input data. More...
 
InOutParameters output_
 Output data. More...
 
bool quiet_
 Suppress output of current time, machine name etc. in the output. More...
 

Detailed Description

Parses an input file and extracts parameters.

The parameters are stored in a separate object in hashes and arrays. Another instance of the same class can be used to store output information.

The output operator writes the date and time in a comment and then content of the input parameters, then "end" and then the content of the output parameters (eg. convergence data). This can be used to generate "unfified" result files where the input data is also present. Advice: put the name of the executable and the command line options in a comment on the first line of the output file.

The format of the input file is the following. Comments are C/C++ style. In an input line, only C-style comments are allowed, the // form is only allowed in otherwise empty lines. An example of an input file:

// Here, it begins
string title "Title of the problem"
double eps   1e-16
bool   debug true
array string bc {
  0 "(0)"
  1 "(x)"
  2 "(y)"
}
int    iter  10
array string bc {
  3 "(x*y)"
}
end
This is ignored

"end" marks the end of the input file, everything after it will be ignored. The possible types are string, double, int and bool (also as arrays – arrays are not allowed to be mixed). An array may be continued (like shown in the example).

The parser is written using a combination of bison(1) and flex(1)

Author
Philipp Frauenfelder, 2000
Examples
hpFEM2d.cc, hpFEM3d-EV.cc, inputoutput.cc, linearDG1d.cc, and linearFEM1d.cc.

Definition at line 443 of file inputOutput.hh.

Member Typedef Documentation

◆ YY_BUFFER_STATE

typedef struct yy_buffer_state* concepts::InputParser::YY_BUFFER_STATE

The buffer representing the input file (for the parser)

Definition at line 467 of file inputOutput.hh.

Constructor & Destructor Documentation

◆ InputParser()

concepts::InputParser::InputParser ( bool  quiet = false)

Default constructor.

Enters the string parameters title, author and comment into the input field with value "(empty)". These may be overriden by the input file.

Parameters
quietIf set to true, the output of the current time, the machine name etc. in the output of this class is suppressed.

◆ ~InputParser()

virtual concepts::InputParser::~InputParser ( )
virtual

Member Function Documentation

◆ info()

virtual std::ostream& concepts::InputParser::info ( std::ostream &  os) const
protectedvirtual

Returns information in an output stream.

Reimplemented from concepts::OutputOperator.

◆ inputParameters()

InOutParameters& concepts::InputParser::inputParameters ( )
inline

Returns the input data.

Examples
hpFEM2d.cc, hpFEM3d-EV.cc, and inputoutput.cc.

Definition at line 461 of file inputOutput.hh.

◆ outputParameters()

InOutParameters& concepts::InputParser::outputParameters ( )
inline

Returns the output data.

Examples
hpFEM2d.cc, hpFEM3d-EV.cc, and inputoutput.cc.

Definition at line 464 of file inputOutput.hh.

◆ parse() [1/2]

void concepts::InputParser::parse ( )

Parses the input file.

Examples
hpFEM2d.cc, hpFEM3d-EV.cc, and inputoutput.cc.

◆ parse() [2/2]

void concepts::InputParser::parse ( std::string  file)

Parses the input file.

Member Data Documentation

◆ current_buffer_

YY_BUFFER_STATE concepts::InputParser::current_buffer_
private

The current input buffer (for the parser)

Definition at line 472 of file inputOutput.hh.

◆ input_

InOutParameters concepts::InputParser::input_
private

Input data.

Definition at line 475 of file inputOutput.hh.

◆ output_

InOutParameters concepts::InputParser::output_
private

Output data.

Definition at line 478 of file inputOutput.hh.

◆ quiet_

bool concepts::InputParser::quiet_
private

Suppress output of current time, machine name etc. in the output.

Definition at line 481 of file inputOutput.hh.


The documentation for this class was generated from the following file:
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich