use std::endl ; error message format ; more comments

This commit is contained in:
Johann Dreo 2010-09-16 09:28:55 +02:00
commit 2ed8146723

View file

@ -23,9 +23,10 @@ void eoFileMonitor::printHeader(std::ostream& os)
for (; it != vec.end(); ++it) for (; it != vec.end(); ++it)
{ {
// use the longName of the eoParam for the header
os << delim.c_str() << (*it)->longName(); os << delim.c_str() << (*it)->longName();
} }
os << '\n'; os << std::endl;
} }
void eoFileMonitor::printHeader() void eoFileMonitor::printHeader()
@ -35,7 +36,7 @@ void eoFileMonitor::printHeader()
if (!os) if (!os)
{ {
string str = "eoFileMonitor: Could not open " + filename; string str = "eoFileMonitor could not open: " + filename;
throw runtime_error(str); throw runtime_error(str);
} }
@ -46,20 +47,25 @@ eoMonitor& eoFileMonitor::operator()(void)
{ {
ofstream os(filename.c_str(), ofstream os(filename.c_str(),
overwrite ? overwrite ?
ios_base::out|ios_base::trunc // FIXME does not seems to work ios_base::out|ios_base::trunc // truncate
: :
ios_base::out|ios_base::app ios_base::out|ios_base::app // append
); );
if (!os) if (!os)
{ {
string str = "eoFileMonitor: Could not write to " + filename; string str = "eoFileMonitor could not write to: " + filename;
throw runtime_error(str); throw runtime_error(str);
} }
if (firstcall && !keep && header ){ if (
printHeader(); header // we want to write headers
firstcall = false; && firstcall // we do not want to write headers twice
&& !keep // if we append to an existing file, headers are useless
&& !overwriting // we do not want to write headers if the file is to be overwriten
) {
printHeader();
firstcall = false;
} }
return operator()(os); return operator()(os);
@ -77,7 +83,8 @@ eoMonitor& eoFileMonitor::operator()(std::ostream& os)
os << delim.c_str() << (*it)->getValue(); os << delim.c_str() << (*it)->getValue();
} }
os << '\n'; os << std::endl;
return *this; return *this;
} }