#include <Cocoa/Cocoa.h>#include <exception>#include <typeinfo>Go to the source code of this file.
Compounds | |
| class | AutoNSExceptionHandler |
| Scope-aware C++ wrapper for NSException's _NSHandler2. More... | |
| class | NSXException |
| Main class & C++ wrapper object for ObjC NSException objects. More... | |
| class | NSXRaisingDestructor |
| Usually raising an ObjC NSException invokes a longjmp out of the current function. More... | |
Defines | |
| #define | NSX_THROW |
| Better version of NSX_DURING/NSX_HANDLER/NSX_ENDHANDLER if you don't need a custom handler (which you usually don't if you're using stack-based objects). | |
| #define | NSX_ENDTHROW |
| Counterpart to NSX_THROW. | |
| #define | NSX_RAISE |
| NSX_THROW's evil twin. | |
| #define | NSX_ENDRAISE |
| Counterpart to NSX_RAISE. | |
| #define | ThrowNSX(CODE) |
| Wraps a line of ObjC code in a handler (which handles raised ObjC exceptions, morphs them into C++ exceptions and throws them). | |
| #define | RaiseNSX(CODE) |
| Wraps a line of C++ code in a try/catch block (which catches thrown C++ exceptions, morphs them into ObjC exceptions and raises them via NSXRaisingDestructor). | |
| #define | NSX_DURING |
| Drop-in replacement for NS_DURING, except uses AutoNSExceptionHandler and thus doesn't require the NS_[VOID|VALUE]RETURN hack. | |
| #define | NSX_HANDLER |
| Denotes beginning of handler block started by NSX_DURING. | |
| #define | NSX_ENDHANDLER |
| Denotes ending of handler block started by NSX_DURING. | |
|
|
Value: { \
AutoNSExceptionHandler handler_; \
if( !_NSSETJMP( handler_._state, 0 ) ) {
Definition at line 436 of file NSXException.h. |
|
|
Value: localException = localException; \
} \
}
Definition at line 459 of file NSXException.h. |
|
|
Value: } catch( const std::exception *x ) { \ raisingDestructor.arm( x ); \ } \ }
Definition at line 338 of file NSXException.h. |
|
|
Value: } else { \ NSXException::Throw( handler_.localException() ); \ } \ }
Definition at line 296 of file NSXException.h. |
|
|
Value: } else { \
NSException *localException = handler_.localException();
Definition at line 448 of file NSXException.h. |
|
|
Value: { \
NSXRaisingDestructor raisingDestructor; \
try {Automatically catches thrown C++ exception pointers, morphs them into ObjC exception objects and raises them via NSXRaisingDestructor. Use it like this:
- (void)foo() {
[obj1 msg1];
[obj2 msg2];
NSX_RAISE
// This will always be destructed, even if an exception is raised below.
auto_ptr<BigStruct> bsOne = new BigStruct();
bsOne->possiblyThrowingMethod();
NSX_ENDRAISE
[obj3 msg3];
}
Definition at line 326 of file NSXException.h. |
|
|
Value: { \
AutoNSExceptionHandler handler_; \
if( !_NSSETJMP( handler_._state, 0 ) ) {Automatically handles raised ObjC exceptions, morphs them into C++ exceptions and throws them. Use it like this:
void foo() { try { // This will always be destructed, even if an exception is raised below. auto_ptr<BigStruct> bsOne = new BigStruct(); NSX_THROW [obj1 msg1]; [obj2 msg2]; safeCFunction(); bsOne->possiblyThrowingMethod(); [obj3 msg3]; NSX_ENDTHROW // The following is never constructed if exception is raised above. auto_ptr<BigStruct> bsTwo = new BigStruct(); } catch( const std::exception *x ) { NSXException::Raise( x ); } }
Definition at line 284 of file NSXException.h. |
|
|
Value: { \
NSXRaisingDestructor raisingDestructor; \
try { \
CODE; \
} catch( const std::exception *x ) { \
raisingDestructor.arm( x ); \
} \
}While easy to use, it bloats produced code, so use it sparingly. (Use NSX_RAISE/NSX_ENDRAISE for long C++ code runs.) Use it like this:
- (void)foo() {
[obj1 msg1];
[obj2 msg2];
RaiseNSX( int result = cppObject->possiblyThrowingMethod() );
[obj3 msg3];
}
Definition at line 410 of file NSXException.h. |
|
|
Value: { \
AutoNSExceptionHandler handler_; \
if( !_NSSETJMP( handler_._state, 0 ) ) { \
CODE; \
} else { \
NSXException::Throw( handler_.localException() ); \
} \
}While easy to use, it bloats produced code, so use it sparingly. (Use NSX_THROW/NSX_ENDTHROW for long ObjC code runs.) Use it like this:
void foo() { try { // This will always be destructed, even if an exception is raised below. auto_ptr<BigStruct> bsOne = new BigStruct(); ThrowNSX( int result = [obj1 msg1] ); bsOne->possiblyThrowingMethod( result ); } catch( const std::exception *x ) { NSXException::Raise( x ); } }
Definition at line 377 of file NSXException.h. |
1.2.17