Add an option to print names in front of values in stream monitor

This commit is contained in:
Johann Dreo 2013-06-13 15:41:03 +02:00
commit 966a5670cb
2 changed files with 15 additions and 4 deletions

View file

@ -47,8 +47,10 @@ eoMonitor& eoOStreamMonitor::operator()(void)
*/
for (iterator it = vec.begin (); it != vec.end (); ++it) {
// value only
out << (*it)->getValue ();
if( print_names ) {
out << (*it)->longName() << name_sep;
}
out << (*it)->getValue();
out << delim << std::left << std::setfill(fill) << std::setw(width);
} // for it in vec

View file

@ -56,8 +56,15 @@ public :
}
*/
eoOStreamMonitor( std::ostream & _out, std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) :
out(_out), delim(_delim), width(_width), fill(_fill), firsttime(true)
eoOStreamMonitor(
std::ostream & _out,
std::string _delim = "\t", unsigned int _width=20, char _fill=' ',
bool _print_names = false, std::string _name_sep = ":"
) :
out(_out),
delim(_delim), width(_width), fill(_fill),
firsttime(true),
print_names(_print_names), name_sep(_name_sep)
{}
eoMonitor& operator()(void);
@ -70,6 +77,8 @@ private :
unsigned int width;
char fill;
bool firsttime;
bool print_names;
std::string name_sep;
};
#endif // _eoOStreamMonitor_h_