summaryrefslogtreecommitdiff
path: root/lib/common/makeexception.pl.in
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common/makeexception.pl.in')
-rwxr-xr-xlib/common/makeexception.pl.in77
1 files changed, 22 insertions, 55 deletions
diff --git a/lib/common/makeexception.pl.in b/lib/common/makeexception.pl.in
index b1b3a8ac..bddaa94a 100755
--- a/lib/common/makeexception.pl.in
+++ b/lib/common/makeexception.pl.in
@@ -73,12 +73,13 @@ class ${class}Exception : public BoxException
public:
${class}Exception(unsigned int SubType,
const std::string& rMessage = "")
- : mSubType(SubType), mMessage(rMessage)
+ : mSubType(SubType), mMessage(rMessage),
+ mWhat(GetMessage(SubType) + std::string(rMessage.empty() ? "" : ": ") + rMessage)
{
}
${class}Exception(const ${class}Exception &rToCopy)
- : mSubType(rToCopy.mSubType), mMessage(rToCopy.mMessage)
+ : mSubType(rToCopy.mSubType), mMessage(rToCopy.mMessage), mWhat(rToCopy.mWhat)
{
}
@@ -113,10 +114,11 @@ print H <<__E;
{
return mMessage;
}
-
+ static const char* GetMessage(int SubType);
private:
unsigned int mSubType;
std::string mMessage;
+ std::string mWhat;
};
#endif // $guardname
@@ -133,74 +135,39 @@ print CPP <<__E;
#include "MemLeakFindOn.h"
-#ifdef EXCEPTION_CODENAMES_EXTENDED
- #ifdef EXCEPTION_CODENAMES_EXTENDED_WITH_DESCRIPTION
-static const char *whats[] = {
-__E
-
-my $last_seen = -1;
-for(my $e = 0; $e <= $#exception; $e++)
+unsigned int ${class}Exception::GetType() const throw()
{
- if($exception[$e] ne '')
- {
- for(my $s = $last_seen + 1; $s < $e; $s++)
- {
- print CPP "\t\"UNUSED\",\n"
- }
- my $ext = ($exception_desc[$e] ne '')?" ($exception_desc[$e])":'';
- print CPP "\t\"${class} ".$exception[$e].$ext.'"'.(($e==$#exception)?'':',')."\n";
- $last_seen = $e;
- }
+ return ${class}Exception::ExceptionType;
}
-print CPP <<__E;
-};
- #else
-static const char *whats[] = {
-__E
-
-$last_seen = -1;
-for(my $e = 0; $e <= $#exception; $e++)
+unsigned int ${class}Exception::GetSubType() const throw()
{
- if($exception[$e] ne '')
- {
- for(my $s = $last_seen + 1; $s < $e; $s++)
- {
- print CPP "\t\"UNUSED\",\n"
- }
- print CPP "\t\"${class} ".$exception[$e].'"'.(($e==$#exception)?'':',')."\n";
- $last_seen = $e;
- }
+ return mSubType;
}
-print CPP <<__E;
-};
- #endif
-#endif
-
-unsigned int ${class}Exception::GetType() const throw()
+const char * ${class}Exception::what() const throw()
{
- return ${class}Exception::ExceptionType;
+ return mWhat.c_str();
}
-unsigned int ${class}Exception::GetSubType() const throw()
+const char * ${class}Exception::GetMessage(int SubType)
{
- return mSubType;
-}
+ switch(SubType)
+ {
+__E
-const char *${class}Exception::what() const throw()
+for(my $e = 0; $e <= $#exception; $e++)
{
-#ifdef EXCEPTION_CODENAMES_EXTENDED
- if(mSubType > (sizeof(whats) / sizeof(whats[0])))
+ if($exception[$e] ne '')
{
- return "${class}";
+ print CPP "\t\tcase ".$exception[$e].': return "'.$exception[$e].'";'."\n";
}
- return whats[mSubType];
-#else
- return "${class}";
-#endif
}
+print CPP <<__E;
+ default: return "Unknown";
+ }
+}
__E
close H;