concepts::InputParser Class Reference
Parses an input file and extracts parameters. More...
#include <inputOutput.hh>
Public Types | |
typedef struct yy_buffer_state * | YY_BUFFER_STATE |
The buffer representing the input file (for the parser) More... | |
Public Member Functions | |
InOutParameters & | inputParameters () |
Returns the input data. More... | |
InputParser (bool quiet=false) | |
Default constructor. More... | |
InOutParameters & | outputParameters () |
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)
- 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
-
quiet If set to true, the output of the current time, the machine name etc. in the output of this class is suppressed.
◆ ~InputParser()
|
virtual |
Member Function Documentation
◆ info()
|
protectedvirtual |
Returns information in an output stream.
Reimplemented from concepts::OutputOperator.
◆ inputParameters()
|
inline |
Returns the input data.
- Examples
- hpFEM2d.cc, hpFEM3d-EV.cc, and inputoutput.cc.
Definition at line 461 of file inputOutput.hh.
◆ 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_
|
private |
The current input buffer (for the parser)
Definition at line 472 of file inputOutput.hh.
◆ input_
|
private |
Input data.
Definition at line 475 of file inputOutput.hh.
◆ output_
|
private |
Output data.
Definition at line 478 of file inputOutput.hh.
◆ 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:
- toolbox/inputOutput.hh