1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #ifndef __MEDMEM_UTILITIES
23 #define __MEDMEM_UTILITIES
25 // standart Linux/Unix functions
31 inline std::string getBaseName( const std::string& dataname ) {
32 std::string aBaseName = "";
34 aBaseName = basename((char*)dataname.c_str());
36 for ( int i = dataname.size()-1; i >= 0; i-- ) {
37 char aSymb = dataname[i];
38 if ( dataname[i] == '\\' || dataname[i] == '/' )
40 aBaseName = dataname[i] + aBaseName;
46 inline std::string getDirName(const std::string& dataname ) {
47 std::string aDirName = "";
49 aDirName = dirname((char*)dataname.c_str());
51 bool aFindLine = false;
52 for ( int i = dataname.size()-1; i >= 0; i-- ) {
53 char aSymb = dataname[i];
55 aFindLine = dataname[i] == '\\' || dataname[i] == '/';
57 aDirName = dataname[i] + aDirName;
66 * \brief Make a name valid. So far, removes white spaces from name end
68 inline std::string healName(const std::string& name ) {
69 size_t last = name.size()-1;
70 while ( last >= 0 && isspace( name[last] ))
72 return name.substr( 0, last + 1 );
79 /* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */
81 # define HEREWEARE_MED {cout<<flush ; cerr << __FILE__ << " [" << __LINE__ << "] : " << flush ;}
82 # define INFOS_MED(chain) {HEREWEARE_MED ; cerr << chain << endl ;}
83 # define PYSCRIPT_MED(chain) {cout<<flush ; cerr << "---PYSCRIPT--- " << chain << endl ;}
86 /* --- To print date and time of compilation of current source on stdout --- */
88 # if defined ( __GNUC__ )
89 # define COMPILER_MED "g++" ;
90 # elif defined ( __sun )
91 # define COMPILER_MED "CC" ;
92 # elif defined ( __KCC )
93 # define COMPILER_MED "KCC" ;
94 # elif defined ( __PGI )
95 # define COMPILER_MED "pgCC" ;
97 # define COMPILER_MED "undefined" ;
100 # ifdef INFOS_COMPILATION_MED
101 # undef INFOS_COMPILATION_MED
103 # define INFOS_COMPILATION_MED {\
106 cout << " [" << __LINE__ << "] : " ;\
107 cout << "COMPILED with " << COMPILER_MED ;\
108 cout << ", " << __DATE__ ; \
109 cout << " at " << __TIME__ << endl ;\
114 #if ( defined(_DEBUG_) || defined(_DEBUG) ) && !defined(_NO_MED_TRACE_)
116 /* --- the following MACROS are useful at debug time --- */
118 # define HERE_MED {cout<<flush ; cerr << "- Trace " << __FILE__ << " [" << __LINE__ << "] : " << flush ;}
119 # define SCRUTE_MED(var) {HERE_MED ; cerr << #var << "=" << var << endl ;}
120 # define MESSAGE_MED(chain) {HERE_MED ; cerr << chain << endl ;}
121 # define INTERRUPTION_MED(code) {HERE_MED ; cerr << "INTERRUPTION return code= " << code << endl ; exit(code) ;}
124 # define ASSERT_MED(condition) if (!(condition)){ HERE_MED ; cerr << "CONDITION " << #condition << " NOT VERIFIED"<< endl ; INTERRUPTION_MED(1) ;}
125 # endif /* ASSERT_MED */
126 #define REPERE_MED {cout<<flush ; cerr << " --------------" << endl << flush ;}
127 #define __PREFIX_MED const char* __LOC_MED
128 #define PREFIX_MED __LOC_MED
129 #define BEGIN_OF_MED(chain) __PREFIX_MED = chain; {REPERE_MED ; HERE_MED ; cerr << "Begin of: " << PREFIX_MED << endl ; REPERE_MED ; }
130 #define END_OF_MED(chain) {REPERE_MED ; HERE_MED ; cerr << "Normal end of: " << chain << endl ; REPERE_MED ; }
133 # else /* ifdef _DEBUG_*/
137 # define SCRUTE_MED(var) {}
138 # define MESSAGE_MED(chain) {}
139 # define INTERRUPTION_MED(code) {}
142 # define ASSERT_MED(condition) {}
146 # define BEGIN_OF_MED(chain) const char* __LOC_MED; {__LOC_MED=chain;}
147 # define END_OF_MED(chain) const char* __LOC_END_MED; {__LOC_END_MED=chain;}
150 #endif /* ifdef _DEBUG_*/