]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Commit the second part of Fahad's patch that was accidentally forgotten :-(
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 23 Apr 2013 01:23:32 +0000 (01:23 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 23 Apr 2013 01:23:32 +0000 (01:23 +0000)
git-svn-id: https://svn.dealii.org/trunk@29362 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/base/logstream.cc

index c5af34880b0bf17b30a0720cf4a97b9c1d1c261d..e0f789346578bc701dfb459dea14c94b1107c3d9 100644 (file)
@@ -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)
 {

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.