Skip to content
Snippets Groups Projects
Commit edb8fd69 authored by Jorrit Fahlke's avatar Jorrit Fahlke
Browse files

ConfigParser: Allow to write the report to an arbitrary C++ stream instead of std::cout only

[[Imported from SVN: r6000]]
parent 746d8959
Branches
Tags
No related merge requests found
......@@ -3,7 +3,8 @@
#include "configparser.hh"
#include <cstdlib>
#include <iostream>
#include <ostream>
#include <string>
#include <sstream>
#include <fstream>
......@@ -126,20 +127,25 @@ void ConfigParser::report() const
}
void ConfigParser::report(const string prefix) const
{
reportStream(std::cout, prefix);
}
void ConfigParser::reportStream(ostream& stream, const string& prefix) const
{
typedef map<string, string>::const_iterator ValueIt;
ValueIt vit = values.begin();
ValueIt vend = values.end();
for(; vit!=vend; ++vit)
cout << vit->first << " = \"" << vit->second << "\"" << endl;
stream << vit->first << " = \"" << vit->second << "\"" << endl;
typedef map<string, ConfigParser>::const_iterator SubIt;
SubIt sit = subs.begin();
SubIt send = subs.end();
for(; sit!=send; ++sit)
{
cout << "[ " << prefix + sit->first << " ]" << endl;
stream << "[ " << prefix + sit->first << " ]" << endl;
(sit->second).report(prefix + sit->first + ".");
}
}
......
......@@ -6,6 +6,7 @@
#include <istream>
#include <map>
#include <ostream>
#include <vector>
#include <string>
#include <iostream>
......@@ -145,6 +146,17 @@ namespace Dune {
void report(const std::string prefix) const;
/** \brief print distinct substructure to stream
*
* Prints all entries with given prefix.
*
* \param stream Stream to print to
* \param prefix for key and substructure names
*/
void reportStream(std::ostream& stream,
const std::string& prefix = "") const;
/** \brief get substructure by name
*
* \param sub substructure name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment