#include "utilities.h"
#include "MEDMEM_Exception.hxx"
+using namespace MEDMEM;
extern "C"
{
}
+/*!
+ \internal
+ Function used to duplicate char *
+*/
const char* duplicate( const char *const str ) ;
-
const char* duplicate( const char *const str )
{
ASSERT(str!=NULL) ;
return new_str ;
}
+/*!
+ \internal Default Constructor (Should not be used)
+*/
+// ------------------------------------------------------ //
MEDEXCEPTION::MEDEXCEPTION( void ): exception() , _text(0)
+// ------------------------------------------------------ //
{
MESSAGE( "You must user the standard builder : MEDEXCEPTION::MEDEXCEPTION( const char *text )" ) ;
INTERRUPTION(1) ;
}
+/*!
+ \internal
+ Function used to elaborate the text of the MEDEXCEPTION
+*/
+// --------------------------------------------------------------------------------------- //
const char *makeText( const char *text, const char *fileName, const unsigned int lineNumber )
+// --------------------------------------------------------------------------------------- //
{
char *newText = 0 ;
const size_t l0 = strlen(prefix) ;
if ( fileName )
- {
+ {
const size_t l2 = strlen(fileName) ;
ASSERT(lineNumber>=1) ;
sprintf( newText , "%s in %s [%u] : %s" , prefix, fileName, lineNumber, text ) ;
ASSERT(newText[l4-1] == '\0' );
- }
+ }
else
- {
+ {
newText = new char [ l0+l1+3+1 ] ;
sprintf( newText , "%s : %s" , prefix, text ) ;
- }
+ }
ASSERT(newText) ;
return newText ;
}
-
-MEDEXCEPTION::MEDEXCEPTION( const char *text, const char *fileName, const unsigned int lineNumber ) : exception(), _text( makeText( text , fileName , lineNumber ) )
+/*!
+ Constructor : \n
+ It will create the text of the MEDEXCEPTION from the different parameters.
+ It will take the form : \n
+ MEDEXCEPTION, fileName, lineNumber and text of the exception
+*/
+// ------------------------------------------------------------------------------------------------ //
+MEDEXCEPTION::MEDEXCEPTION( const char *text, const char *fileName, const unsigned int lineNumber ) :
+ exception(), _text( makeText( text , fileName , lineNumber ) )
+// ------------------------------------------------------------------------------------------------ //
{
MESSAGE(_text);
}
+/*!
+ Destructor : \n
+ If necessary desallocates Memory
+*/
+// ------------------------------------//
MEDEXCEPTION::~MEDEXCEPTION() throw ()
+// ------------------------------------//
{
if ( _text )
{
}
-
+/*!
+ Copy Constructor : \n
+ Should not be used very often
+*/
+// ----------------------------------------------------------------------- //
MEDEXCEPTION::MEDEXCEPTION( const MEDEXCEPTION &ex ): _text(duplicate(ex._text))
+// ----------------------------------------------------------------------- //
{
;
}
-
-
-ostream & operator<<( ostream &os , const MEDEXCEPTION &ex )
+/*!
+ Operator << : put the message to the given stream.
+*/
+// ------------------------------------------------------- //
+ostream & MEDMEM::operator<<( ostream &os , const MEDEXCEPTION &ex )
+// ------------------------------------------------------- //
{
os << ex._text ;
return os ;
}
-
-
+/*!
+ Return a char * which contain the message.
+*/
+// ------------------------------------------------- //
const char* MEDEXCEPTION::what( void ) const throw ()
+// ------------------------------------------------- //
{
return _text ;
}