1 // Copyright (C) 2003 CEA/DEN, EDF R&D
5 // File : VISU_DatConvertor.hxx
6 // Author : Alexey PETROV
9 #ifndef MED_Utilities_HeaderFile
10 #define MED_Utilities_HeaderFile
27 static string GetPrefix();
31 * @returns \p false when error occured, \p true otherwise.
32 * Adjusts the \p in_stream to the beginning of the
35 inline bool beginning_of_dataset(std::istream& in_file, const std::string& ds_name)
37 assert (in_file.good());
38 assert (!ds_name.empty());
40 std::string olds, news;
43 in_file >> olds >> news;
45 * a "-1" followed by a number means the beginning of a dataset
46 * stop combing at the end of the file
48 while( ((olds != "-1") || (news == "-1") ) && !in_file.eof() ){
57 // should never end up here
62 * Method for converting exponential notation
63 * from "D" to "e", for example
64 * \p 3.141592654D+00 \p --> \p 3.141592654e+00
65 * in order to make it readable for C++.
67 inline double D_to_e(std::string& number)
69 /* find "D" in string, start looking at
70 * 6th element, to improve speed.
71 * We dont expect a "D" earlier
73 const int position = number.find("D",6);
74 if(position != std::string::npos){
75 number.replace(position, 1, "e");
77 return atof (number.c_str());
85 #define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"<<msg<<endl;
87 #define BEGMSG(msg) std::cout<<UNV::PrefixPrinter::GetPrefix()<<msg
89 #define ADDMSG(msg) std::cout<<msg
96 #define EXCEPTION(TYPE, MSG) {\
97 std::ostringstream aStream;\
98 aStream<<__FILE__<<"["<<__LINE__<<"]::"<<MSG;\
99 throw TYPE(aStream.str());\