ReactOS 0.4.16-dev-320-g3bd9ddc
ATL::CComBSTR Class Reference

#include <atlcomcli.h>

Public Member Functions

 CComBSTR ()
 
 CComBSTR (LPCOLESTR pSrc)
 
 CComBSTR (int length)
 
 CComBSTR (int length, LPCOLESTR pSrc)
 
 CComBSTR (PCSTR pSrc)
 
 CComBSTR (const CComBSTR &other)
 
 CComBSTR (REFGUID guid)
 
 ~CComBSTR ()
 
 operator BSTR () const
 
BSTRoperator& ()
 
CComBSTRoperator= (const CComBSTR &other)
 
void Attach (BSTR bstr)
 
BSTR Detach ()
 
BSTR Copy () const
 
HRESULT CopyTo (BSTR *other) const
 
bool LoadString (HMODULE module, DWORD uID)
 
unsigned int Length () const
 
unsigned int ByteLength () const
 

Public Attributes

BSTR m_str
 

Detailed Description

Definition at line 287 of file atlcomcli.h.

Constructor & Destructor Documentation

◆ CComBSTR() [1/7]

ATL::CComBSTR::CComBSTR ( )
inline

Definition at line 292 of file atlcomcli.h.

292 :
293 m_str(NULL)
294 {
295 }
#define NULL
Definition: types.h:112

◆ CComBSTR() [2/7]

ATL::CComBSTR::CComBSTR ( LPCOLESTR  pSrc)
inline

Definition at line 297 of file atlcomcli.h.

298 {
299 if (pSrc == NULL)
300 m_str = NULL;
301 else
302 m_str = ::SysAllocString(pSrc);
303 }
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238

◆ CComBSTR() [3/7]

ATL::CComBSTR::CComBSTR ( int  length)
inline

Definition at line 305 of file atlcomcli.h.

306 {
307 if (length == 0)
308 m_str = NULL;
309 else
311 }
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339

◆ CComBSTR() [4/7]

ATL::CComBSTR::CComBSTR ( int  length,
LPCOLESTR  pSrc 
)
inline

Definition at line 313 of file atlcomcli.h.

314 {
315 if (length == 0)
316 m_str = NULL;
317 else
319 }

◆ CComBSTR() [5/7]

ATL::CComBSTR::CComBSTR ( PCSTR  pSrc)
inline

Definition at line 321 of file atlcomcli.h.

322 {
323 if (pSrc)
324 {
325 int len = MultiByteToWideChar(CP_THREAD_ACP, 0, pSrc, -1, NULL, 0);
327 if (m_str)
328 {
329 int res = MultiByteToWideChar(CP_THREAD_ACP, 0, pSrc, -1, m_str, len);
330 ATLASSERT(res == len);
331 if (res != len)
332 {
334 m_str = NULL;
335 }
336 }
337 }
338 else
339 {
340 m_str = NULL;
341 }
342 }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define MultiByteToWideChar
Definition: compat.h:110
GLuint res
Definition: glext.h:9613
GLenum GLsizei len
Definition: glext.h:6722
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define CP_THREAD_ACP
Definition: winnls.h:235

◆ CComBSTR() [6/7]

ATL::CComBSTR::CComBSTR ( const CComBSTR other)
inline

Definition at line 344 of file atlcomcli.h.

345 {
346 m_str = other.Copy();
347 }
int other
Definition: msacm.c:1376

◆ CComBSTR() [7/7]

ATL::CComBSTR::CComBSTR ( REFGUID  guid)
inline

Definition at line 349 of file atlcomcli.h.

350 {
351 OLECHAR szGuid[40];
354 }
WCHAR OLECHAR
Definition: compat.h:2292
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
const GUID * guid
static const WCHAR szGuid[]
Definition: rtlstr.c:1892

◆ ~CComBSTR()

ATL::CComBSTR::~CComBSTR ( )
inline

Definition at line 356 of file atlcomcli.h.

357 {
359 m_str = NULL;
360 }

Member Function Documentation

◆ Attach()

void ATL::CComBSTR::Attach ( BSTR  bstr)
inline

Definition at line 379 of file atlcomcli.h.

380 {
382 m_str = bstr;
383 }

◆ ByteLength()

unsigned int ATL::CComBSTR::ByteLength ( ) const
inline

Definition at line 423 of file atlcomcli.h.

424 {
425 return ::SysStringByteLen(m_str);
426 }

◆ Copy()

BSTR ATL::CComBSTR::Copy ( ) const
inline

Definition at line 392 of file atlcomcli.h.

393 {
394 if (!m_str)
395 return NULL;
396 return ::SysAllocStringLen(m_str, ::SysStringLen(m_str));
397 }
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:196

Referenced by CopyTo().

◆ CopyTo()

HRESULT ATL::CComBSTR::CopyTo ( BSTR other) const
inline

Definition at line 399 of file atlcomcli.h.

400 {
401 if (!other)
402 return E_POINTER;
403 *other = Copy();
404 return S_OK;
405 }
BSTR Copy() const
Definition: atlcomcli.h:392
#define S_OK
Definition: intsafe.h:52
#define E_POINTER
Definition: winerror.h:2365

◆ Detach()

BSTR ATL::CComBSTR::Detach ( )
inline

Definition at line 385 of file atlcomcli.h.

386 {
387 BSTR str = m_str;
388 m_str = NULL;
389 return str;
390 }
OLECHAR * BSTR
Definition: compat.h:2293
const WCHAR * str

◆ Length()

unsigned int ATL::CComBSTR::Length ( ) const
inline

Definition at line 418 of file atlcomcli.h.

419 {
420 return ::SysStringLen(m_str);
421 }

◆ LoadString()

bool ATL::CComBSTR::LoadString ( HMODULE  module,
DWORD  uID 
)
inline

Definition at line 407 of file atlcomcli.h.

408 {
410 m_str = NULL;
411 const wchar_t *ptr = NULL;
412 int len = ::LoadStringW(module, uID, (PWSTR)&ptr, 0);
413 if (len)
415 return m_str != NULL;
416 }
static PVOID ptr
Definition: dispmode.c:27
uint16_t * PWSTR
Definition: typedefs.h:56
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)

◆ operator BSTR()

ATL::CComBSTR::operator BSTR ( ) const
inline

Definition at line 362 of file atlcomcli.h.

363 {
364 return m_str;
365 }

◆ operator&()

BSTR * ATL::CComBSTR::operator& ( )
inline

Definition at line 367 of file atlcomcli.h.

368 {
369 return &m_str;
370 }

◆ operator=()

CComBSTR & ATL::CComBSTR::operator= ( const CComBSTR other)
inline

Definition at line 372 of file atlcomcli.h.

373 {
375 m_str = other.Copy();
376 return *this;
377 }

Member Data Documentation

◆ m_str


The documentation for this class was generated from the following file: