1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef MED_Utilities_HeaderFile
21 #define MED_Utilities_HeaderFile
23 #include "SMESH_DriverUNV.hxx"
34 class MESHDRIVERUNV_EXPORT PrefixPrinter{
40 static string GetPrefix();
44 * @returns \p false when error occured, \p true otherwise.
45 * Adjusts the \p in_stream to the beginning of the
48 inline bool beginning_of_dataset(std::istream& in_file, const std::string& ds_name)
50 assert (in_file.good());
51 assert (!ds_name.empty());
53 std::string olds, news;
56 in_file >> olds >> news;
58 * a "-1" followed by a number means the beginning of a dataset
59 * stop combing at the end of the file
61 while( ((olds != "-1") || (news == "-1") ) && !in_file.eof() ){
70 // should never end up here
75 * Method for converting exponential notation
76 * from "D" to "e", for example
77 * \p 3.141592654D+00 \p --> \p 3.141592654e+00
78 * in order to make it readable for C++.
80 inline double D_to_e(std::string& number)
82 /* find "D" in string, start looking at
83 * 6th element, to improve speed.
84 * We dont expect a "D" earlier
86 const int position = number.find("D",6);
87 if(position != std::string::npos){
88 number.replace(position, 1, "e");
90 return atof (number.c_str());
98 #define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"<<msg<<endl;
100 #define BEGMSG(msg) std::cout<<UNV::PrefixPrinter::GetPrefix()<<msg
102 #define ADDMSG(msg) std::cout<<msg
109 #define EXCEPTION(TYPE, MSG) {\
110 std::ostringstream aStream;\
111 aStream<<__FILE__<<"["<<__LINE__<<"]::"<<MSG;\
112 throw TYPE(aStream.str());\