![]() | InDesign SDK 20.5 |
#include <AutoXRef.h>
Public Member Functions | |
| AutoXRef (IDataBase *sourceDB, IDataBase *targetDB) | |
| ~AutoXRef () | |
Automatically calls IXReferenceUID::BeginXRefSession in constructor and IXReferenceUID::EndXRefSession in destructor so you do not have to explicitly to call BeginXRefSession and EndXRefSession. Just create an AutoXRef stack object and you are done. Prevents problems with early returns forgetting to call EndXRefSession and leaving a session open.
e.g. the following code:
InterfacePtr<IXReferenceUID> xRef(GetExecutionContextSession(), IID_IXREFERENCEUID); if (xRef) xRef->BeginXRefSession(sourceDB, targetDB); ... Some code here ... if (xRef) xRef->EndXRefSession(sourceDB, targetDB);
would become:
AutoXRef autoXRef(sourceDB, targetDB); Some code here
When the AutoXRef object is created, BeginXRefSession is called, and likewise when the AutoXRef goes out of scope, EndXRefSession is called. You can force the destructor by using scoping brackets { } as necessary so you don't have to leave the XRefSession open longer than necessary.
| inline |
Destructor