From e084b5530f20769efb22690e099cff39e28a06b1 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 24 Apr 2013 15:53:38 +0000 Subject: [PATCH] Set flags, width, precision directly on the underlying stream object. git-svn-id: https://svn.dealii.org/trunk@29383 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/base/logstream.h | 31 ++------------------- deal.II/source/base/logstream.cc | 34 ++++-------------------- 2 files changed, 7 insertions(+), 58 deletions(-) diff --git a/deal.II/include/deal.II/base/logstream.h b/deal.II/include/deal.II/base/logstream.h index 574cc5309a..98617b69a8 100644 --- a/deal.II/include/deal.II/base/logstream.h +++ b/deal.II/include/deal.II/base/logstream.h @@ -531,27 +531,6 @@ private: */ bool at_newline; - /** - * The flags used to modify how - * the stream returned by get_stream() is used. - */ - std::ios_base::fmtflags stream_flags; - - /** - * The minimum width of characters - * used to represent a number. Used by width() to - * change the stream return by get_stream() - */ - std::streamsize stream_width; - - /** - * The maximum width of characters - * used to represent a floating point number. - * Used by precision() to - * change the stream return by get_stream() - */ - std::streamsize stream_precision; - /** * Print head of line. This prints optional time information and the * contents of the prefix stack. @@ -604,12 +583,8 @@ inline LogStream & LogStream::operator<< (const T &t) { - // save the state of the output stream - std::ostringstream &stream = get_stream(); - - // print to the internal stringstream, using the flags we have just set for - // the stream object: - stream << t; + // print to the internal stringstream + get_stream() << t; return *this; } @@ -620,7 +595,6 @@ inline LogStream & LogStream::operator<< (const double t) { - // save the state of out stream std::ostringstream &stream = get_stream(); // we have to make sure that we don't catch NaN's and +-Inf's with the @@ -643,7 +617,6 @@ inline LogStream & LogStream::operator<< (const float t) { - // save the state of out stream std::ostringstream &stream = get_stream(); // we have to make sure that we don't catch NaN's and +-Inf's with the diff --git a/deal.II/source/base/logstream.cc b/deal.II/source/base/logstream.cc index 7594dc2750..588f1af187 100644 --- a/deal.II/source/base/logstream.cc +++ b/deal.II/source/base/logstream.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -57,10 +57,7 @@ LogStream::LogStream() float_threshold(0.), offset(0), old_cerr(0), - at_newline(true), - stream_flags(std::ios::showpoint | std::ios::left), - stream_width(std::cout.width()), - stream_precision(std::cout.precision()) + at_newline(true) { get_prefixes().push("DEAL:"); @@ -134,10 +131,6 @@ 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; @@ -170,11 +163,6 @@ 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; } @@ -260,33 +248,21 @@ void LogStream::pop () std::ios::fmtflags LogStream::flags(const std::ios::fmtflags f) { - Threads::Mutex::ScopedLock lock(log_lock); - - std::ios::fmtflags tmp = stream_flags; - stream_flags = f; - return tmp; + return get_stream().flags (f); } std::streamsize LogStream::precision (const std::streamsize prec) { - Threads::Mutex::ScopedLock lock(log_lock); - - std::streamsize tmp = stream_precision; - stream_precision = prec; - return tmp; + return get_stream().precision (prec); } std::streamsize LogStream::width (const std::streamsize wide) { - Threads::Mutex::ScopedLock lock(log_lock); - - std::streamsize tmp = stream_width; - stream_width = wide; - return tmp; + return get_stream().width (wide); } -- 2.39.5