]> OCCT Git - occt-copy.git/commitdiff
0031862: [REGRESSION] Coding - Flags of output stream are modified CR31862
authorBenjamin Bihler <benjamin.bihler@compositence.de>
Mon, 19 Oct 2020 09:09:13 +0000 (11:09 +0200)
committerBenjamin Bihler <benjamin.bihler@compositence.de>
Mon, 19 Oct 2020 09:09:13 +0000 (11:09 +0200)
Added RAII class to restore stream flags after dump.

src/AppDef/AppDef_Variational.cxx

index 25b86f3d7567f1cade5491492ce5410d1283a921..39089f78129a01ccb72698f563354f75227b232c 100644 (file)
@@ -897,6 +897,31 @@ Standard_Integer AppDef_Variational::NbIterations() const
 //
 void AppDef_Variational::Dump(Standard_OStream& o) const 
 {
+  class StreamFlagRestorer
+  {
+   public:
+
+    explicit StreamFlagRestorer(std::ostream& stream) :
+      stream(stream), flags(stream.flags())
+    {
+    }
+
+    ~StreamFlagRestorer()
+    {
+      stream.flags(flags);
+    }
+
+    StreamFlagRestorer(const StreamFlagRestorer& rhs) = delete;
+    StreamFlagRestorer& operator=(const StreamFlagRestorer& rhs) = delete;
+
+   private:
+
+    std::ostream& stream;
+    std::ios::fmtflags flags;
+  };
+
+  StreamFlagRestorer restorer(o);
+
   o << " \nVariational Smoothing " << std::endl;
   o << " Number of multipoints                   "  << myNbPoints << std::endl;
   o << " Number of 2d par multipoint "  << myNbP2d << std::endl;
@@ -923,7 +948,7 @@ void AppDef_Variational::Dump(Standard_OStream& o) const
   else
   { if (myIsOverConstr) o << "The probleme is overconstraint " << std::endl;
   else o << " Erreur dans l''approximation" << std::endl;
-  }   
+  }
 }
 //
 //=======================================================================