Reputation: 3020
How to test if a CComBSTR
is an empty string? (with no 'text' value, can be ""
or can be null
)
my ideas:
CComBSTR::ByteLength()
returns 0CComBSTR::GetStreamSize()
returns 0CComBSTR::m_str
is NULLCComBSTR::Length()
returns 0which one is correct approach? if none of them is, then what is correct approach?
thanks.
Upvotes: 3
Views: 3191
Reputation: 26001
3) test if CComBSTR::m_str is NULL
If you check the source code of CComBSTR there's several operators you can use to do this test:
bool CComBSTR::operator!() const throw()
bool CComBSTR::operator!=(int nNull) const throw()
bool CComBSTR::operator==(int nNull) const throw()
operator CComBSTR::BSTR() const throw()
For example:
CComBSTR value;
if (!value) { /* NULL */ } else { /* not NULL */ }
if (value != NULL) { /* not NULL */ } else { /* NULL */ }
if (value == NULL) { /* NULL */ } else { /* not NULL */ }
if ((BSTR) value) { /* not NULL */ } else { /* NULL */ }
Upvotes: 0