STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
_bstr_t Class Reference

#include <comutil.h>

Classes

class  Data_t
 

Public Member Functions

 _bstr_t () throw ()
 
 _bstr_t (const _bstr_t &s) throw ()
 
 _bstr_t (const char *s)
 
 _bstr_t (const wchar_t *s)
 
 _bstr_t (const _variant_t &var)
 
 _bstr_t (BSTR bstr, bool fCopy)
 
 ~_bstr_t () throw ()
 
_bstr_toperator= (const _bstr_t &s) throw ()
 
_bstr_toperator= (const char *s)
 
_bstr_toperator= (const wchar_t *s)
 
_bstr_toperator= (const _variant_t &var)
 
_bstr_toperator+= (const _bstr_t &s)
 
_bstr_t operator+ (const _bstr_t &s) const
 
 operator const wchar_t * () const throw ()
 
 operator wchar_t * () const throw ()
 
 operator const char * () const
 
 operator char * () const
 
bool operator! () const throw ()
 
bool operator== (const _bstr_t &str) const throw ()
 
bool operator!= (const _bstr_t &str) const throw ()
 
bool operator< (const _bstr_t &str) const throw ()
 
bool operator> (const _bstr_t &str) const throw ()
 
bool operator<= (const _bstr_t &str) const throw ()
 
bool operator>= (const _bstr_t &str) const throw ()
 
BSTR copy (bool fCopy=true) const
 
unsigned int length () const throw ()
 
void Assign (BSTR s)
 
BSTR & GetBSTR ()
 
BSTR * GetAddress ()
 
void Attach (BSTR s)
 
BSTR Detach ()
 

Private Member Functions

void _AddRef () throw ()
 
void _Free () throw ()
 
int _Compare (const _bstr_t &str) const throw ()
 

Private Attributes

Data_tm_Data
 

Friends

_bstr_t operator+ (const char *s1, const _bstr_t &s2)
 
_bstr_t operator+ (const wchar_t *s1, const _bstr_t &s2)
 

Constructor & Destructor Documentation

_bstr_t::_bstr_t ( )
throw (
)
inline
296  : m_Data(NULL)
297 {
298 }
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
_bstr_t::_bstr_t ( const _bstr_t s)
throw (
)
inline
303  : m_Data(s.m_Data)
304 {
305  _AddRef();
306 }
Data_t * m_Data
Definition: comutil.h:277
void _AddRef()
Definition: comutil.h:626
_bstr_t::_bstr_t ( const char *  s)
inline
311  : m_Data(new Data_t(s))
312 {
313  if (m_Data == NULL) {
314  _com_issue_error(E_OUTOFMEMORY);
315  }
316 }
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
void __stdcall _com_issue_error(HRESULT)
_bstr_t::_bstr_t ( const wchar_t s)
inline
321  : m_Data(new Data_t(s))
322 {
323  if (m_Data == NULL) {
324  _com_issue_error(E_OUTOFMEMORY);
325  }
326 }
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
void __stdcall _com_issue_error(HRESULT)
_bstr_t::_bstr_t ( const _variant_t var)
inline
2346  : m_Data(NULL)
2347 {
2348  if (V_VT(&var) == VT_BSTR) {
2349  *this = V_BSTR(&var);
2350  return;
2351  }
2352 
2353  _variant_t varDest;
2354  varDest.ChangeType(VT_BSTR, &var);
2355 
2356  *this = V_BSTR(&varDest);
2357 }
void ChangeType(VARTYPE vartype, const _variant_t *pSrc=NULL)
Definition: comutil.h:2305
Definition: comutil.h:1002
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
_bstr_t::_bstr_t ( BSTR  bstr,
bool  fCopy 
)
inline
332  : m_Data(new Data_t(bstr, fCopy))
333 {
334  if (m_Data == NULL) {
335  _com_issue_error(E_OUTOFMEMORY);
336  }
337 }
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
void __stdcall _com_issue_error(HRESULT)
_bstr_t::~_bstr_t ( )
throw (
)
inline
342 {
343  _Free();
344 }
void _Free()
Definition: comutil.h:635

Member Function Documentation

void _bstr_t::_AddRef ( )
throw (
)
inlineprivate
627 {
628  if (m_Data != NULL) {
629  m_Data->AddRef();
630  }
631 }
#define NULL
Definition: crtdbg.h:30
unsigned long AddRef()
Definition: comutil.h:765
Data_t * m_Data
Definition: comutil.h:277
int _bstr_t::_Compare ( const _bstr_t str) const
throw (
)
inlineprivate
646 {
647  if (m_Data == str.m_Data) {
648  return 0;
649  }
650 
651  if (m_Data == NULL) {
652  if (str.length() == 0) {
653  return 0;
654  }
655  else {
656  return -1;
657  }
658  }
659 
660  if (str.m_Data == NULL){
661  if (this->length() == 0) {
662  return 0;
663  }
664  else {
665  return 1;
666  }
667  }
668 
669  return m_Data->Compare(*str.m_Data);
670 }
int Compare(const Data_t &str) const
Definition: comutil.h:876
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
unsigned int length() const
Definition: comutil.h:552
void _bstr_t::_Free ( )
throw (
)
inlineprivate
636 {
637  if (m_Data != NULL) {
638  m_Data->Release();
639  m_Data = NULL;
640  }
641 }
unsigned long Release()
Definition: comutil.h:771
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
void _bstr_t::Assign ( BSTR  s)
inline
560 {
561  _COM_ASSERT(s == NULL || m_Data == NULL || m_Data->GetWString() != s);
562 
563  if (s == NULL || m_Data == NULL || m_Data->GetWString() != s)
564  {
565  _Free();
566 
567  m_Data = new Data_t(s, TRUE);
568  if (m_Data == NULL) {
569  _com_issue_error(E_OUTOFMEMORY);
570  }
571  }
572 }
void _Free()
Definition: comutil.h:635
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
void __stdcall _com_issue_error(HRESULT)
const wchar_t * GetWString() const
Definition: comutil.h:812
#define _COM_ASSERT(x)
Definition: comutil.h:26
void _bstr_t::Attach ( BSTR  s)
inline
598 {
599  _Free();
600 
601  m_Data = new Data_t(s, FALSE);
602  if (m_Data == NULL) {
603  _com_issue_error(E_OUTOFMEMORY);
604  }
605 }
void _Free()
Definition: comutil.h:635
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
void __stdcall _com_issue_error(HRESULT)
BSTR _bstr_t::copy ( bool  fCopy = true) const
inline
546 {
547  return (m_Data != NULL) ? (fCopy ? m_Data->Copy() : m_Data->GetWString()) : NULL;
548 }
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
const wchar_t * GetWString() const
Definition: comutil.h:812
BSTR Copy() const
Definition: comutil.h:833
BSTR _bstr_t::Detach ( )
inline
610 {
611  _COM_ASSERT(m_Data != NULL && m_Data->RefCount() == 1);
612 
613  if (m_Data != NULL && m_Data->RefCount() == 1) {
614  BSTR b = m_Data->GetWString();
615  m_Data->GetWString() = NULL;
616  _Free();
617  return b;
618  }
619  else {
620  _com_issue_error(E_POINTER);
621  }
622 }
unsigned long RefCount() const
Definition: comutil.h:781
void _Free()
Definition: comutil.h:635
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
void __stdcall _com_issue_error(HRESULT)
const wchar_t * GetWString() const
Definition: comutil.h:812
#define _COM_ASSERT(x)
Definition: comutil.h:26
BSTR * _bstr_t::GetAddress ( )
inline
590 {
591  Attach(0);
592  return &m_Data->GetWString();
593 }
void Attach(BSTR s)
Definition: comutil.h:597
Data_t * m_Data
Definition: comutil.h:277
const wchar_t * GetWString() const
Definition: comutil.h:812
BSTR & _bstr_t::GetBSTR ( )
inline
577 {
578  if (m_Data == NULL) {
579  m_Data = new Data_t(0, FALSE);
580  if (m_Data == NULL) {
581  _com_issue_error(E_OUTOFMEMORY);
582  }
583  }
584  return m_Data->GetWString();
585 }
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
void __stdcall _com_issue_error(HRESULT)
const wchar_t * GetWString() const
Definition: comutil.h:812
unsigned int _bstr_t::length ( ) const
throw (
)
inline
553 {
554  return (m_Data != NULL) ? m_Data->Length() : 0;
555 }
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
unsigned int Length() const
Definition: comutil.h:869
_bstr_t::operator char * ( ) const
inline
492 {
493  return const_cast<char*>((m_Data != NULL) ? m_Data->GetString() : NULL);
494 }
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
const char * GetString() const
Definition: comutil.h:822
_bstr_t::operator const char * ( ) const
inline
485 {
486  return (m_Data != NULL) ? m_Data->GetString() : NULL;
487 }
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
const char * GetString() const
Definition: comutil.h:822
_bstr_t::operator const wchar_t * ( ) const
throw (
)
inline
471 {
472  return (m_Data != NULL) ? m_Data->GetWString() : NULL;
473 }
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
const wchar_t * GetWString() const
Definition: comutil.h:812
_bstr_t::operator wchar_t * ( ) const
throw (
)
inline
478 {
479  return const_cast<wchar_t*>((m_Data != NULL) ? m_Data->GetWString() : NULL);
480 }
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
const wchar_t * GetWString() const
Definition: comutil.h:812
bool _bstr_t::operator! ( ) const
throw (
)
inline
503 {
504  return (m_Data != NULL) ? !m_Data->GetWString() : true;
505 }
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
const wchar_t * GetWString() const
Definition: comutil.h:812
bool _bstr_t::operator!= ( const _bstr_t str) const
throw (
)
inline
513 {
514  return _Compare(str) != 0;
515 }
int _Compare(const _bstr_t &str) const
Definition: comutil.h:645
_bstr_t _bstr_t::operator+ ( const _bstr_t s) const
inline
429 {
430  _bstr_t b = *this;
431  b += s;
432 
433  return b;
434 }
Definition: comutil.h:144
_bstr_t & _bstr_t::operator+= ( const _bstr_t s)
inline
413 {
414  Data_t* newData = new Data_t(*this, s);
415  if (newData == NULL) {
416  _com_issue_error(E_OUTOFMEMORY);
417  }
418  else {
419  _Free();
420  m_Data = newData;
421  }
422 
423  return *this;
424 }
void _Free()
Definition: comutil.h:635
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
void __stdcall _com_issue_error(HRESULT)
bool _bstr_t::operator< ( const _bstr_t str) const
throw (
)
inline
518 {
519  return _Compare(str) < 0;
520 }
int _Compare(const _bstr_t &str) const
Definition: comutil.h:645
bool _bstr_t::operator<= ( const _bstr_t str) const
throw (
)
inline
528 {
529  return _Compare(str) <= 0;
530 }
int _Compare(const _bstr_t &str) const
Definition: comutil.h:645
_bstr_t & _bstr_t::operator= ( const _bstr_t s)
throw (
)
inline
355 {
356  if (this != &s) {
357  _Free();
358 
359  m_Data = s.m_Data;
360  _AddRef();
361  }
362 
363  return *this;
364 }
void _Free()
Definition: comutil.h:635
Data_t * m_Data
Definition: comutil.h:277
void _AddRef()
Definition: comutil.h:626
_bstr_t & _bstr_t::operator= ( const char *  s)
inline
369 {
370  _COM_ASSERT(s == NULL || static_cast<const char*>(*this) != s);
371 
372  if (s == NULL || static_cast<const char*>(*this) != s)
373  {
374  _Free();
375 
376  m_Data = new Data_t(s);
377  if (m_Data == NULL) {
378  _com_issue_error(E_OUTOFMEMORY);
379  }
380  }
381 
382  return *this;
383 }
void _Free()
Definition: comutil.h:635
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
void __stdcall _com_issue_error(HRESULT)
#define _COM_ASSERT(x)
Definition: comutil.h:26
_bstr_t & _bstr_t::operator= ( const wchar_t s)
inline
388 {
389  _COM_ASSERT(s == NULL || static_cast<const wchar_t*>(*this) != s);
390 
391  if (s == NULL || static_cast<const wchar_t*>(*this) != s)
392  {
393  _Free();
394 
395  m_Data = new Data_t(s);
396  if (m_Data == NULL) {
397  _com_issue_error(E_OUTOFMEMORY);
398  }
399  }
400 
401  return *this;
402 }
void _Free()
Definition: comutil.h:635
#define NULL
Definition: crtdbg.h:30
Data_t * m_Data
Definition: comutil.h:277
void __stdcall _com_issue_error(HRESULT)
#define _COM_ASSERT(x)
Definition: comutil.h:26
_bstr_t & _bstr_t::operator= ( const _variant_t var)
inline
2362 {
2363  if (V_VT(&var) == VT_BSTR) {
2364  *this = V_BSTR(&var);
2365  return *this;
2366  }
2367 
2368  _variant_t varDest;
2369  varDest.ChangeType(VT_BSTR, &var);
2370 
2371  *this = V_BSTR(&varDest);
2372 
2373  return *this;
2374 }
void ChangeType(VARTYPE vartype, const _variant_t *pSrc=NULL)
Definition: comutil.h:2305
Definition: comutil.h:1002
bool _bstr_t::operator== ( const _bstr_t str) const
throw (
)
inline
508 {
509  return _Compare(str) == 0;
510 }
int _Compare(const _bstr_t &str) const
Definition: comutil.h:645
bool _bstr_t::operator> ( const _bstr_t str) const
throw (
)
inline
523 {
524  return _Compare(str) > 0;
525 }
int _Compare(const _bstr_t &str) const
Definition: comutil.h:645
bool _bstr_t::operator>= ( const _bstr_t str) const
throw (
)
inline
533 {
534  return _Compare(str) >= 0;
535 }
int _Compare(const _bstr_t &str) const
Definition: comutil.h:645

Friends And Related Function Documentation

_bstr_t operator+ ( const char *  s1,
const _bstr_t s2 
)
friend
445 {
446  _bstr_t b = s1;
447  b += s2;
448 
449  return b;
450 }
Definition: comutil.h:144
_bstr_t operator+ ( const wchar_t s1,
const _bstr_t s2 
)
friend
455 {
456  _bstr_t b = s1;
457  b += s2;
458 
459  return b;
460 }
Definition: comutil.h:144

Member Data Documentation

Data_t* _bstr_t::m_Data
private

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