aboutsummaryrefslogtreecommitdiff
path: root/src/exception.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-05-26 04:03:24 +0000
committerMike Buland <eichlan@xagasoft.com>2006-05-26 04:03:24 +0000
commitbd5bb1ca60a6a97b110cbf221b3625e6e6200141 (patch)
tree063b1576b57aba698159f50a04461ddfb7c4dfb6 /src/exception.cpp
parentbc6f456ef27bdf25bf7a7f677217b9b7204b4241 (diff)
downloadlibbu++-bd5bb1ca60a6a97b110cbf221b3625e6e6200141.tar.gz
libbu++-bd5bb1ca60a6a97b110cbf221b3625e6e6200141.tar.bz2
libbu++-bd5bb1ca60a6a97b110cbf221b3625e6e6200141.tar.xz
libbu++-bd5bb1ca60a6a97b110cbf221b3625e6e6200141.zip
Loads of updates to several systems, see each for what really changed, the
biggest are the updates to the exception framework, and to the pproc system, which is almost a competitor to popt already...
Diffstat (limited to '')
-rw-r--r--src/exception.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/exception.cpp b/src/exception.cpp
index 11f04a9..291a198 100644
--- a/src/exception.cpp
+++ b/src/exception.cpp
@@ -5,12 +5,9 @@ Exception::Exception( const char *lpFormat, ... ) throw() :
5 nErrorCode( 0 ) 5 nErrorCode( 0 )
6{ 6{
7 va_list ap; 7 va_list ap;
8 int nSize;
9 8
10 va_start(ap, lpFormat); 9 va_start(ap, lpFormat);
11 nSize = vsnprintf( NULL, 0, lpFormat, ap ); 10 setWhat( lpFormat, ap );
12 sWhat = new char[nSize+1];
13 vsnprintf( sWhat, nSize+1, lpFormat, ap );
14 va_end(ap); 11 va_end(ap);
15} 12}
16 13
@@ -18,20 +15,32 @@ Exception::Exception( int nCode, const char *lpFormat, ... ) throw() :
18 nErrorCode( nCode ) 15 nErrorCode( nCode )
19{ 16{
20 va_list ap; 17 va_list ap;
21 int nSize;
22 18
23 va_start(ap, lpFormat); 19 va_start(ap, lpFormat);
24 nSize = vsnprintf( NULL, 0, lpFormat, ap ); 20 setWhat( lpFormat, ap );
25 sWhat = new char[nSize+1];
26 vsnprintf( sWhat, nSize+1, lpFormat, ap );
27 va_end(ap); 21 va_end(ap);
28} 22}
29 23
24Exception::Exception( int nCode ) throw() :
25 nErrorCode( nCode ),
26 sWhat( NULL )
27{
28}
29
30Exception::~Exception() throw() 30Exception::~Exception() throw()
31{ 31{
32 delete[] sWhat; 32 delete[] sWhat;
33} 33}
34 34
35void Exception::setWhat( const char *lpFormat, va_list &vargs )
36{
37 int nSize;
38
39 nSize = vsnprintf( NULL, 0, lpFormat, vargs );
40 sWhat = new char[nSize+1];
41 vsnprintf( sWhat, nSize+1, lpFormat, vargs );
42}
43
35const char *Exception::what() const throw() 44const char *Exception::what() const throw()
36{ 45{
37 return sWhat; 46 return sWhat;