stringcomvisual-studio-2005atlbstr

how to test if CComBSTR is empty


How to test if a CComBSTR is an empty string? (with no 'text' value, can be "" or can be null)

my ideas:

  1. test if CComBSTR::ByteLength() returns 0
  2. test if CComBSTR::GetStreamSize() returns 0
  3. test if CComBSTR::m_str is NULL
  4. test if CComBSTR::Length() returns 0

which one is correct approach? if none of them is, then what is correct approach?

thanks.


Solution

  • 4) Test length 0 it's fast as it's stored