Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef MED_Utilities_HeaderFile
00024 #define MED_Utilities_HeaderFile
00025
00026 #include "SMESH_DriverUNV.hxx"
00027
00028 #include <iostream>
00029 #include <sstream>
00030 #include <fstream>
00031 #include <string>
00032 #include <stdexcept>
00033 #include <cassert>
00034 #include <cstdlib>
00035
00036 namespace UNV{
00037 using namespace std;
00038
00039 class MESHDRIVERUNV_EXPORT PrefixPrinter{
00040 static int myCounter;
00041 public:
00042 PrefixPrinter();
00043 ~PrefixPrinter();
00044
00045 static string GetPrefix();
00046 };
00047
00053 inline bool beginning_of_dataset(std::istream& in_file, const std::string& ds_name)
00054 {
00055 assert (in_file.good());
00056 assert (!ds_name.empty());
00057
00058 std::string olds, news;
00059
00060 while(true){
00061 in_file >> olds >> news;
00062
00063
00064
00065
00066 while( ((olds != "-1") || (news == "-1") ) && !in_file.eof() ){
00067 olds = news;
00068 in_file >> news;
00069 }
00070 if(in_file.eof())
00071 return false;
00072 if (news == ds_name)
00073 return true;
00074 }
00075
00076 return false;
00077 }
00078
00085 inline double D_to_e(std::string& number)
00086 {
00087
00088
00089
00090
00091 const int position = number.find("D",6);
00092 if(position != std::string::npos){
00093 number.replace(position, 1, "e");
00094 }
00095 return atof (number.c_str());
00096 }
00097
00103 inline bool check_file(const std::string theFileName)
00104 {
00105 std::ifstream in_stream(theFileName.c_str());
00106 if (!in_stream)
00107 return false;
00108 std::string olds, news;
00109 while (!in_stream.eof()){
00110 olds = news;
00111 std::getline(in_stream, news, '\n');
00112 }
00113 return (olds == " -1");
00114 }
00115
00116 };
00117
00118
00119 #ifndef MESSAGE
00120
00121 #define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"<<msg<<endl;
00122
00123 #define BEGMSG(msg) std::cout<<UNV::PrefixPrinter::GetPrefix()<<msg
00124
00125 #define ADDMSG(msg) std::cout<<msg
00126
00127 #endif
00128
00129
00130 #ifndef EXCEPTION
00131
00132 #define EXCEPTION(TYPE, MSG) {\
00133 std::ostringstream aStream;\
00134 aStream<<__FILE__<<"["<<__LINE__<<"]::"<<MSG;\
00135 throw TYPE(aStream.str());\
00136 }
00137
00138 #endif
00139
00140 #endif