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