OpenLB 1.8.1
Loading...
Searching...
No Matches
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 37 of file xmlReaderOutput.h.

Constructor & Destructor Documentation

◆ XMLreaderOutput() [1/3]

olb::XMLreaderOutput::XMLreaderOutput ( )
inline

Definition at line 51 of file xmlReaderOutput.h.

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

◆ XMLreaderOutput() [2/3]

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

Definition at line 52 of file xmlReaderOutput.h.

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

◆ XMLreaderOutput() [3/3]

olb::XMLreaderOutput::XMLreaderOutput ( OutputChannel outputChannel)

Definition at line 60 of file xmlReaderOutput.h.

60 : clout(std::cerr, "xmlReaderOutput"){
61 if (outputChannel == OutputChannel::TERMINAL){
62 clout = OstreamManager(std::cout, "xmlReaderOutput");
63 }
64 else if (outputChannel == OutputChannel::ERRCHANNEL){
65 clout = OstreamManager(std::cerr, "xmlReaderOutput");
66 } else{
67 clout = OstreamManager(std::cerr, "xmlReaderOutput");
68 }
69#ifdef OLB_DEBUG
70 _inDebugMode = true;
71#endif
72}

References _inDebugMode, clout, olb::ERRCHANNEL, and olb::TERMINAL.

Member Function Documentation

◆ loadFile()

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

Definition at line 104 of file xmlReaderOutput.h.

105{
106 if (!loadOK) {
107 clout << std::string("Problem processing input XML file ") << fName << std::endl;
108 }
109}

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 75 of file xmlReaderOutput.h.

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

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 137 of file xmlReaderOutput.h.

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

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 119 of file xmlReaderOutput.h.

121{
122
123 if ( verboseOn ) {
124 clout << "Warning: Cannot read " << typeName << " value from XML element " << name << "." << std::endl;
125 if ( ! value.empty() ) {
126 clout << " Setting default value = " << value << std::endl;
127 }
128 }
129 if ( exitIfMissing ) {
130 clout << "Error: This program cannot continue without \"" << name << "\". Optimization aborted." << std::endl;
131 exit(1);
132 }
133}
std::string name()
Returns name of FIELD for human consumption.
Definition fields.h:49
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 111 of file xmlReaderOutput.h.

112{
113 if ( warningsOn ) {
114 clout << "Warning: cannot read value from node \"" << name << "\"" << ", \"" << fName <<"\"" << std::endl;
115 }
116}

References clout.

+ Here is the caller graph for this function:

Member Data Documentation

◆ _inDebugMode

bool olb::XMLreaderOutput::_inDebugMode = false
protected

Definition at line 57 of file xmlReaderOutput.h.

◆ clout

OstreamManager olb::XMLreaderOutput::clout
mutableprotected

Definition at line 56 of file xmlReaderOutput.h.


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