Back to index

salome-kernel  6.5.0
Functions
Utils_SALOME_Exception.cxx File Reference
#include <iostream>
#include "Utils_SALOME_Exception.hxx"
#include "utilities.h"
#include <math.h>
#include <stdio.h>
#include <string.h>

Go to the source code of this file.

Functions

const char * duplicate (const char *const str)
 This function can be changed by strdup() if strdup() is ANSI.
const char * makeText (const char *text, const char *fileName, const unsigned int lineNumber)
std::ostream & operator<< (std::ostream &os, const SALOME_Exception &ex)

Function Documentation

const char* duplicate ( const char *const  str)

This function can be changed by strdup() if strdup() is ANSI.

It is strongly (and only) used in the Registry environment (RegistryService, RegistryConnexion, Identity, ...)

Definition at line 42 of file duplicate.cxx.

{
        ASSERT(str!=NULL) ;
        const size_t length = strlen( str ) ;
        ASSERT(length>0) ;
        char *new_str = new char[ 1+length ] ;
        ASSERT(new_str) ;
        strcpy( new_str , str ) ;
        return new_str ;
}

Here is the caller graph for this function:

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:

std::ostream& operator<< ( std::ostream &  os,
const SALOME_Exception &  ex 
)

Definition at line 111 of file Utils_SALOME_Exception.cxx.

{
        os << ex._text ;
        return os ;
}