Commit 85c1a04e authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Mesh writers: avoid reference in class members, initialize by rdbuf

Using references as class members is weird, because they cannot extend
the lifetime of the objects they are initialized with. Using values of
the type std::ostream and initializing by rdbuf (which is a pointer)
works better, probably because the underlying rdbuf generally outlives
the ostreams that were being passed to the writers.
parent b8fa05a2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ public:
   PVTUWriter() = delete;

   PVTUWriter( std::ostream& str, VTK::FileFormat format = VTK::FileFormat::zlib_compressed )
   : str(str), format(format)
   : str(str.rdbuf()), format(format)
   {}

   // If desired, cycle and time of the simulation can put into the file. This follows the instructions at
@@ -79,7 +79,7 @@ protected:

   void writeFooter();

   std::ostream& str;
   std::ostream str;

   VTK::FileFormat format;

+2 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ public:
   VTKWriter() = delete;

   VTKWriter( std::ostream& str, VTK::FileFormat format = VTK::FileFormat::binary )
   : str(str), format(format)
   : str(str.rdbuf()), format(format)
   {
      if( format != VTK::FileFormat::ascii && format != VTK::FileFormat::binary )
         throw std::domain_error("The Legacy VTK file formats support only ASCII and BINARY formats.");
@@ -78,7 +78,7 @@ protected:

   void writeHeader();

   std::ostream& str;
   std::ostream str;

   VTK::FileFormat format;

+2 −2
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ public:
   VTUWriter() = delete;

   VTUWriter( std::ostream& str, VTK::FileFormat format = VTK::FileFormat::zlib_compressed )
   : str(str), format(format)
   : str(str.rdbuf()), format(format)
   {}

   // If desired, cycle and time of the simulation can put into the file. This follows the instructions at
@@ -78,7 +78,7 @@ protected:

   void writeFooter();

   std::ostream& str;
   std::ostream str;

   VTK::FileFormat format;