diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
| commit | f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 (patch) | |
| tree | 13cdf64f7cf134f397a7165b7a3fe0807e37026b /src/old/exceptionbase.cpp | |
| parent | 74d4c8cd27334fc7204d5a8773deb3d424565778 (diff) | |
| download | libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.gz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.bz2 libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.xz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.zip | |
Ok, no code is left in src, it's all in src/old. We'll gradually move code back
into src as it's fixed and re-org'd. This includes tests, which, I may write a
unit test system into libbu++ just to make my life easier.
Diffstat (limited to 'src/old/exceptionbase.cpp')
| -rw-r--r-- | src/old/exceptionbase.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/old/exceptionbase.cpp b/src/old/exceptionbase.cpp new file mode 100644 index 0000000..f3d22da --- /dev/null +++ b/src/old/exceptionbase.cpp | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | #include "exceptionbase.h" | ||
| 2 | #include <stdarg.h> | ||
| 3 | |||
| 4 | ExceptionBase::ExceptionBase( const char *lpFormat, ... ) throw() : | ||
| 5 | nErrorCode( 0 ), | ||
| 6 | sWhat( NULL ) | ||
| 7 | { | ||
| 8 | va_list ap; | ||
| 9 | |||
| 10 | va_start(ap, lpFormat); | ||
| 11 | setWhat( lpFormat, ap ); | ||
| 12 | va_end(ap); | ||
| 13 | } | ||
| 14 | |||
| 15 | ExceptionBase::ExceptionBase( int nCode, const char *lpFormat, ... ) throw() : | ||
| 16 | nErrorCode( nCode ), | ||
| 17 | sWhat( NULL ) | ||
| 18 | { | ||
| 19 | va_list ap; | ||
| 20 | |||
| 21 | va_start(ap, lpFormat); | ||
| 22 | setWhat( lpFormat, ap ); | ||
| 23 | va_end(ap); | ||
| 24 | } | ||
| 25 | |||
| 26 | ExceptionBase::ExceptionBase( int nCode ) throw() : | ||
| 27 | nErrorCode( nCode ), | ||
| 28 | sWhat( NULL ) | ||
| 29 | { | ||
| 30 | } | ||
| 31 | |||
| 32 | ExceptionBase::~ExceptionBase() throw() | ||
| 33 | { | ||
| 34 | if( sWhat ) | ||
| 35 | { | ||
| 36 | delete[] sWhat; | ||
| 37 | sWhat = NULL; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | void ExceptionBase::setWhat( const char *lpFormat, va_list &vargs ) | ||
| 42 | { | ||
| 43 | if( sWhat ) delete[] sWhat; | ||
| 44 | int nSize; | ||
| 45 | |||
| 46 | nSize = vsnprintf( NULL, 0, lpFormat, vargs ); | ||
| 47 | sWhat = new char[nSize+1]; | ||
| 48 | vsnprintf( sWhat, nSize+1, lpFormat, vargs ); | ||
| 49 | } | ||
| 50 | |||
| 51 | void ExceptionBase::setWhat( const char *lpText ) | ||
| 52 | { | ||
| 53 | if( sWhat ) delete[] sWhat; | ||
| 54 | int nSize; | ||
| 55 | |||
| 56 | nSize = strlen( lpText ); | ||
| 57 | sWhat = new char[nSize+1]; | ||
| 58 | strcpy( sWhat, lpText ); | ||
| 59 | } | ||
| 60 | |||
| 61 | const char *ExceptionBase::what() const throw() | ||
| 62 | { | ||
| 63 | return sWhat; | ||
| 64 | } | ||
| 65 | |||
| 66 | int ExceptionBase::getErrorCode() | ||
| 67 | { | ||
| 68 | return nErrorCode; | ||
| 69 | } | ||
| 70 | |||
