Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/smesh.git] / src / DriverUNV / UNV_Utilities.hxx
index 6f8598341b0e378ce8473ee5b6ba3ed44f8e16e0..cb6135351d78d33a58fb7f0ece58e96c3b47df7f 100644 (file)
 #ifndef MED_Utilities_HeaderFile
 #define MED_Utilities_HeaderFile
 
+#include "SMESH_DriverUNV.hxx"
+
 #include <iostream>    
 #include <sstream>     
+#include <fstream>
 #include <string>
 #include <stdexcept>
 #include <cassert>
@@ -29,7 +32,7 @@
 namespace UNV{
   using namespace std;
 
-  class PrefixPrinter{
+  class MESHDRIVERUNV_EXPORT PrefixPrinter{
     static int myCounter;
   public:
     PrefixPrinter();
@@ -87,6 +90,24 @@ namespace UNV{
     }
     return atof (number.c_str());
   }
+  
+  /**
+   * @returns \p false when file is incorrect, \p true otherwise.
+   * Check file with name \p theFileName for correct terminate
+   * string, i.e. the next to the last line is equal to "    -1",
+   */
+  inline bool check_file(const std::string theFileName)
+  {
+    std::ifstream in_stream(theFileName.c_str());
+    if (!in_stream)
+      return false;
+    std::string olds, news;
+    while (!in_stream.eof()){
+      olds = news;
+      std::getline(in_stream, news, '\n');
+    }
+    return (olds == "    -1");
+  }
 
 };