The CTempBSTR template class wraps an OLE BSTR object. When used to maintain references on BSTR objects returned by SQL-DMO, the class ensures that references are released when:
SQLDMO_BSTR b( );
Returns a SQLDMO_BSTR from the instance without incrementing the reference count maintained on the BSTR. Returns NULL if the instance is not maintaining a reference.
CTempBSTR( );
CTempBSTR(SQLDMO_BSTR bstrIn);
Creates an instance of the class.
void Free( );
Safely releases a BSTR reference maintained by the instance. The function is provided for class completeness. Class destruction and assignment operator implementations ensure reference release and the use of Free is not required by an application.
operator SQLDMO_LPCSTR ( );
Returns a SQLDMO_LPCSTR pointing to the character string maintained by the BSTR object wrapped. Returns NULL if the instance is not maintaining a reference on a BSTR object.
operator void* ( );
Returns a void pointer to the memory maintaining a BSTR object reference.
SQLDMO_BSTR operator = (SQLDMO_BSTR bstrIn);
If a BSTR reference is maintained by the instance, the reference is released. The instance maintains the reference on the BSTR object assigned to the instance. Returns the reference assigned.
SQLDMO_BSTR* operator & ( );
Returns a pointer to the memory maintaining a BSTR object reference as a pointer to a SQLDMO_BSTR.
BOOL operator ! ( );
Returns FALSE when an instance maintains a reference on a BSTR object. Returns TRUE otherwise.