Go to the documentation of this file.00001 #ifndef __NITRO_EXCEPTION_CPP__
00002 #define __NITRO_EXCEPTION_CPP__
00003
00004 #include <string.h>
00005
00006 #include <utilities/cpp_utilities.h>
00007 #include <utilities/exception.h>
00008 #include <utilities/testing_utilities.h>
00009
00010 namespace nitro
00011 {
00012 exception::exception( void ) : CodeInfo( 0 )
00013 {
00014 memset( WhatInfo , 0 , EXCEPTION_MESSAGE_LENGTH );
00015 }
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 exception::exception( const std::string & theWhatInfo , int theCodeInfo )
00026 {
00027 memset( WhatInfo , 0 , EXCEPTION_MESSAGE_LENGTH );
00028 strncpy( WhatInfo , theWhatInfo.c_str() , ( std::size_t )( EXCEPTION_MESSAGE_LENGTH - 1 ) < ( std::size_t )( theWhatInfo.size() + 1 ) ? ( std::size_t )( EXCEPTION_MESSAGE_LENGTH - 1 ) : ( std::size_t )( theWhatInfo.size() + 1 ) );
00029
00030 CodeInfo = theCodeInfo;
00031 }
00032
00033 const char * exception::what( void ) const
00034 {
00035 return( WhatInfo );
00036 }
00037
00038 int exception::code( void ) const
00039 {
00040 return( CodeInfo );
00041 }
00042
00043 exception::~exception()
00044 {
00045 }
00046
00047 BEGIN_TESTING_SECTION()
00048
00049 ENABLE_CLASS_TESTING( exception )
00050
00051 #ifdef ENABLE_AUTOTESTING
00052 NITRO_EXPORTING void tstSet( const char * ObjectName , const char * Message , int Code )
00053 {
00054 GET_OBJECT( exception , ObjectName ) = exception( Message , Code );
00055 }
00056 #endif
00057
00058 CLASS_MEMBER_FUNCTION_TESTING_0( exception , what , tstWhat , const char * , const char * )
00059 CLASS_MEMBER_FUNCTION_TESTING_0( exception , code , tstCode , int , int )
00060
00061 END_TESTING_SECTION()
00062 }
00063
00064 #endif