From b6587a8b74a907902974a34556adce6760984380 Mon Sep 17 00:00:00 2001 From: bangerth Date: Tue, 23 Apr 2013 01:23:32 +0000 Subject: [PATCH] Commit the second part of Fahad's patch that was accidentally forgotten :-( git-svn-id: https://svn.dealii.org/trunk@29362 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/base/logstream.cc | 42 +++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/deal.II/source/base/logstream.cc b/deal.II/source/base/logstream.cc index c5af34880b..e0f7893465 100644 --- a/deal.II/source/base/logstream.cc +++ b/deal.II/source/base/logstream.cc @@ -57,7 +57,10 @@ LogStream::LogStream() float_threshold(0.), offset(0), old_cerr(0), - at_newline(true) + at_newline(true), + stream_flags(std::ios::showpoint | std::ios::left), + stream_width(std::cout.width()), + stream_precision(std::cout.precision()) { get_prefixes().push("DEAL:"); @@ -129,7 +132,12 @@ LogStream::test_mode(bool on) LogStream & LogStream::operator<< (std::ostream& (*p) (std::ostream &)) { + std::ostringstream &stream = get_stream(); + // save the state of out stream + std::ios::fmtflags old_flags = stream.flags(stream_flags); + unsigned int old_precision = stream.precision (stream_precision); + unsigned int old_width = stream.width (stream_width); // Print to the internal stringstream: stream << p; @@ -162,6 +170,11 @@ LogStream::operator<< (std::ostream& (*p) (std::ostream &)) stream.str(""); } + // reset output format + stream.flags (old_flags); + stream.precision(old_precision); + stream.width(old_width); + return *this; } @@ -244,6 +257,33 @@ void LogStream::pop () } +std::ios::fmtflags +LogStream::flags(const std::ios::fmtflags f) +{ + std::ios::fmtflags tmp = stream_flags; + stream_flags = f; + return tmp; +} + + +std::streamsize +LogStream::precision (const std::streamsize prec) +{ + std::streamsize tmp = stream_precision; + stream_precision = prec; + return tmp; +} + + +std::streamsize +LogStream::width (const std::streamsize wide) +{ + std::streamsize tmp = stream_width; + stream_width = wide; + return tmp; +} + + unsigned int LogStream::depth_console (const unsigned int n) { -- 2.39.5