Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.0 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. wsbbstrg.h
  5. Abstract:
  6. This component is C++ object representations a smart BSTR pointer. It
  7. is similar to the CComPtr, in that it takes care of allocating and
  8. freeing the memory needed to represent the string automatically. This
  9. simplifies cleanup of functions in error handling cases and it limits
  10. the need for FinalConstruct() and FinalRelease() calls in objects that
  11. derive from CComObjectRoot. It is similar to the CWsbStringPtr class.
  12. Author:
  13. Chuck Bardeen [cbardeen] 11-Dec-1996
  14. Revision History:
  15. --*/
  16. #ifndef _WSBBSTRG_
  17. #define _WSBBSTRG_
  18. /*++
  19. Class Name:
  20. CWsbBstrPtr
  21. Class Description:
  22. This component is C++ object representations a smart BSTR pointer. It
  23. is similar to the CComPtr, in that it takes care of allocating and
  24. freeing the memory needed to represent the string automatically. This
  25. simplifies cleanup of functions in error handling cases and it limits
  26. the need for FinalConstruct() and FinalRelease() calls in objects that
  27. derive from CComObjectRoot. It is similar to the CWsbStringPtr class.
  28. --*/
  29. class WSB_EXPORT CWsbBstrPtr
  30. {
  31. // Constructors
  32. public:
  33. CWsbBstrPtr();
  34. CWsbBstrPtr(const CHAR* pChar);
  35. CWsbBstrPtr(const WCHAR* pWchar);
  36. CWsbBstrPtr(const CWsbBstrPtr& pString);
  37. CWsbBstrPtr(REFGUID rguid);
  38. // Destructor
  39. public:
  40. ~CWsbBstrPtr();
  41. // Operator Overloading
  42. public:
  43. operator BSTR();
  44. WCHAR& operator *();
  45. BSTR* operator &();
  46. WCHAR& operator [](const int i);
  47. CWsbBstrPtr& operator =(const CHAR* pChar);
  48. CWsbBstrPtr& operator =(const WCHAR* pWchar);
  49. CWsbBstrPtr& operator =(REFGUID rguid);
  50. CWsbBstrPtr& operator =(const CWsbBstrPtr& pString);
  51. BOOL operator !();
  52. // Memory Allocation
  53. public:
  54. HRESULT Alloc(ULONG size);
  55. HRESULT Free(void);
  56. HRESULT GetSize(ULONG* size);
  57. HRESULT Realloc(ULONG size);
  58. // String Manipulation
  59. public:
  60. HRESULT Append(const CHAR* pChar);
  61. HRESULT Append(const WCHAR* pWchar);
  62. HRESULT Append(const CWsbBstrPtr& pString);
  63. HRESULT CopyTo(CHAR** pChar);
  64. HRESULT CopyTo(WCHAR** pWchar);
  65. HRESULT CopyTo(GUID * pguid);
  66. HRESULT CopyToBstr(BSTR* pBstr);
  67. HRESULT CopyTo(CHAR** pChar, ULONG bufferSize);
  68. HRESULT CopyTo(WCHAR** pWchar,ULONG bufferSize);
  69. HRESULT CopyToBstr(BSTR* pBstr,ULONG bufferSize);
  70. HRESULT FindInRsc(ULONG startId, ULONG idsToCheck, ULONG* pMatchId);
  71. HRESULT GiveTo(BSTR* pBstr);
  72. HRESULT LoadFromRsc(HINSTANCE instance, ULONG id);
  73. HRESULT Prepend(const CHAR* pChar);
  74. HRESULT Prepend(const WCHAR* pWchar);
  75. HRESULT Prepend(const CWsbBstrPtr& pString);
  76. HRESULT TakeFrom(BSTR bstr, ULONG bufferSize);
  77. // Guid Translation
  78. public:
  79. // Member Data
  80. protected:
  81. BSTR m_pString;
  82. ULONG m_givenSize;
  83. };
  84. #endif // _WSBBSTRG