OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
olb::XMLreaderOutput Class Reference

#include <xmlReaderOutput.h>

+ Collaboration diagram for olb::XMLreaderOutput:

Public Member Functions

template<typename ParameterType >
void parameterReading (std::vector< std::string > parameters, ParameterType &var, bool defaultAvailable, bool exitIfMissing, bool showWarning) const
 
void loadFile (bool loadOK, std::string fName) const
 
void readValue (bool warningsOn, std::string name, std::string fName) const
 
void printWarning (std::string name, std::string typeName, std::string value, bool verboseOn, bool exitIfMissing) const
 print warning if verbose mode is on and exit, if exItMissing is true
 
template<typename XMLreaderType >
void print (int indent, XMLreaderType &xmlReader) const
 printing the whole structure of the XMLreader
 
 XMLreaderOutput ()
 
 XMLreaderOutput (std::ostream &stream)
 
 XMLreaderOutput (OutputChannel outputChannel)
 

Protected Attributes

OstreamManager clout
 
bool _inDebugMode = false
 

Detailed Description

Definition at line 32 of file xmlReaderOutput.h.

Constructor & Destructor Documentation

◆ XMLreaderOutput() [1/3]

olb::XMLreaderOutput::XMLreaderOutput ( )
inline

Definition at line 46 of file xmlReaderOutput.h.

46: clout(std::cerr, "xmlReaderOutput"){}

◆ XMLreaderOutput() [2/3]

olb::XMLreaderOutput::XMLreaderOutput ( std::ostream & stream)
inline

Definition at line 47 of file xmlReaderOutput.h.

47: clout(stream, "xmlReaderOutput"){}

◆ XMLreaderOutput() [3/3]

olb::XMLreaderOutput::XMLreaderOutput ( OutputChannel outputChannel)

Definition at line 55 of file xmlReaderOutput.h.

55 : clout(std::cerr, "xmlReaderOutput"){
56 if (outputChannel == OutputChannel::TERMINAL){
57 clout = OstreamManager(std::cout, "xmlReaderOutput");
58 }
59 else if (outputChannel == OutputChannel::ERRCHANNEL){
60 clout = OstreamManager(std::cerr, "xmlReaderOutput");
61 } else{
62 clout = OstreamManager(std::cerr, "xmlReaderOutput");
63 }
64#ifdef OLB_DEBUG
65 _inDebugMode = true;
66#endif
67}

References _inDebugMode, clout, ERRCHANNEL, and TERMINAL.

Member Function Documentation

◆ loadFile()

void olb::XMLreaderOutput::loadFile ( bool loadOK,
std::string fName ) const

Definition at line 99 of file xmlReaderOutput.h.

100{
101 if (!loadOK) {
102 clout << std::string("Problem processing input XML file ") << fName << std::endl;
103 }
104}

References clout.

+ Here is the caller graph for this function:

◆ parameterReading()

template<typename ParameterType >
void olb::XMLreaderOutput::parameterReading ( std::vector< std::string > parameters,
ParameterType & var,
bool defaultAvailable,
bool exitIfMissing,
bool showWarning ) const

Definition at line 70 of file xmlReaderOutput.h.

75{
76 if (showWarning || _inDebugMode) {
77 clout << "Warning: Cannot read parameter from XML File: ";
78 std::for_each(parameters.begin(), parameters.end(), [this](const std::string name_parameter)
79 { clout << "<" << name_parameter << ">"; });
80 clout << std::endl;
81
82 if ( exitIfMissing ) {
83 clout << "Error: This program cannot continue without ";
84 std::for_each(parameters.begin(), parameters.end(), [this](const std::string name_parameter)
85 { clout << "<" << name_parameter << ">"; });
86 clout << ". Optimization aborted." << std::endl;
87 exit(1);
88 }
89 if (defaultAvailable) {
90 clout << "\t Setting default value: " << parameters.back() << " = "<< var << std::endl;
91 }
92 else {
93 clout << "\t Setting arbitrarily: " << parameters.back() << " = " << var << std::endl;
94 }
95 }
96}
void exit(int exitcode)
Definition singleton.h:165

References _inDebugMode, and clout.

+ Here is the caller graph for this function:

◆ print()

template<typename XMLreaderType >
void olb::XMLreaderOutput::print ( int indent,
XMLreaderType & xmlReader ) const

printing the whole structure of the XMLreader

Definition at line 132 of file xmlReaderOutput.h.

132 {
133 std::string indentStr(indent, ' ');
134 clout << indentStr << "[" << xmlReader.getName() << "]" << std::endl;
135 if (!xmlReader.getText().empty()) {
136 clout << indentStr << " " << xmlReader.getText() << std::endl;
137 }
138 for (unsigned int iNode=0; iNode<xmlReader._children.size(); ++iNode) {
139 xmlReader._children[iNode]->_output.print(indent+2,*xmlReader._children[iNode]);
140 }
141}

References clout.

◆ printWarning()

void olb::XMLreaderOutput::printWarning ( std::string name,
std::string typeName,
std::string value,
bool verboseOn,
bool exitIfMissing ) const

print warning if verbose mode is on and exit, if exItMissing is true

Definition at line 114 of file xmlReaderOutput.h.

116{
117
118 if ( verboseOn ) {
119 clout << "Warning: Cannot read " << typeName << " value from XML element " << name << "." << std::endl;
120 if ( ! value.empty() ) {
121 clout << " Setting default value = " << value << std::endl;
122 }
123 }
124 if ( exitIfMissing ) {
125 clout << "Error: This program cannot continue without \"" << name << "\". Optimization aborted." << std::endl;
126 exit(1);
127 }
128}
std::string name()
Returns distinct name on GCC, Clang and ICC but may return arbitrary garbage as per the standard.
Definition meta.h:100
typename std::integral_constant< TYPE, VALUE >::type value
Identity type to wrap non-type template arguments.
Definition meta.h:96

References clout.

+ Here is the caller graph for this function:

◆ readValue()

void olb::XMLreaderOutput::readValue ( bool warningsOn,
std::string name,
std::string fName ) const

Definition at line 106 of file xmlReaderOutput.h.

107{
108 if ( warningsOn ) {
109 clout << "Warning: cannot read value from node \"" << name << "\"" << ", \"" << fName <<"\"" << std::endl;
110 }
111}

References clout.

+ Here is the caller graph for this function:

Member Data Documentation

◆ _inDebugMode

bool olb::XMLreaderOutput::_inDebugMode = false
protected

Definition at line 52 of file xmlReaderOutput.h.

◆ clout

OstreamManager olb::XMLreaderOutput::clout
mutableprotected

Definition at line 51 of file xmlReaderOutput.h.


The documentation for this class was generated from the following file: