Back to index

salome-kernel  6.5.0
Classes | Defines | Functions
DSC_Exception.hxx File Reference
#include "Utils_SALOME_Exception.hxx"
#include <string>
#include <iostream>
#include <sstream>
#include <memory>
#include "utilities.h"
#include <string.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  OSS
 Class OSS is useful when streaming data through a function that expect a string as parameter. More...
struct  DSC_Exception

Defines

#define LOC(message)   (message)
#define DSC_EXCEPTION(Derived)
#define DSC_EXCEPTION_CXX(NameSpace, Derived)   NameSpace::Derived::~Derived(void) throw() {};

Functions

const char * makeText (const char *text, const char *fileName, const unsigned int lineNumber)

Define Documentation

#define DSC_EXCEPTION (   Derived)
Value:
struct Derived : public DSC_Exception { \
  Derived ( const std::string & text, const char *fileName="", const unsigned int lineNumber=0, const char *funcName="" \
            ) : DSC_Exception(text,fileName,lineNumber,funcName) {      \
    _exceptionName = #Derived; \
  } \
    virtual ~Derived(void) throw();\
};\

Definition at line 168 of file DSC_Exception.hxx.

#define DSC_EXCEPTION_CXX (   NameSpace,
  Derived 
)    NameSpace::Derived::~Derived(void) throw() {};

Definition at line 179 of file DSC_Exception.hxx.

#define LOC (   message)    (message)

Definition at line 55 of file DSC_Exception.hxx.


Function Documentation

const char* makeText ( const char *  text,
const char *  fileName,
const unsigned int  lineNumber 
)

Definition at line 55 of file Utils_SALOME_Exception.cxx.

{
        char *newText = 0 ;

        ASSERT(text) ;
        const size_t l1 = 1+strlen(text) ;
        ASSERT(l1>1) ;

        const char* prefix = "Salome Exception" ;
        const size_t l0 = 2+strlen(prefix) ;

        if ( fileName )
        {
                const size_t l2 = 4+strlen(fileName) ;
                ASSERT(l2>4) ;

                ASSERT(lineNumber>=1) ;
                const size_t l3 = 4+int(log10(float(lineNumber))) ;
                
                newText = new char [ 1+l0+l1+l2+l3 ] ;
                sprintf( newText , "%s in %s [%u] : %s" , prefix, fileName, lineNumber, text ) ;
        }
        else
        {
                newText = new char [ 1+l0+l1 ] ;
                sprintf( newText , "%s : %s" , prefix, text ) ;
        }
        ASSERT(newText) ;
        return newText ;
}

Here is the caller graph for this function: