Source code of Windows XP (NT5)
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.

113 lines
3.1 KiB

  1. #ifndef _HXX_FBSTR
  2. #define _HXX_FBSTR
  3. //+---------------------------------------------------------------------------
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  7. //
  8. // File: fbstr.hxx
  9. //
  10. // Contents: Wrappers around BSTR api to account for wierdness with NULL
  11. //
  12. // Functions: STRVAL
  13. // ADsIsEmptyString
  14. // ADsAllocString
  15. // ADsAllocStringLen
  16. // ADsReAllocString
  17. // ADsReAllocStringLen
  18. // ADsFreeString
  19. // ADsStringLen
  20. // ADsStringByteLen
  21. // ADsAllocStringByteLen
  22. // ADsStringCmp
  23. // ADsStringNCmp
  24. // ADsStringICmp
  25. // ADsStringNICmp
  26. //
  27. // History: 25-Apr-94 adams Created
  28. // 02-Jun-94 doncl removed TCHAR usage
  29. // 7-20-94 adams Added ADsIsEmptyString
  30. // 1-3-95 krishnaG Forms* > ADs*
  31. //
  32. //----------------------------------------------------------------------------
  33. typedef const OLECHAR * CBSTR;
  34. const WCHAR EMPTYSTRING[] = L"";
  35. //+---------------------------------------------------------------------------
  36. //
  37. // Function: STRVAL
  38. //
  39. // Synopsis: Returns the string unless it is NULL, in which case the empty
  40. // string is returned.
  41. //
  42. // History: 06-May-94 adams Created
  43. // 02-Jun-94 doncl changed to STRVAL/LPCWSTR instead of
  44. // TSTRVAL/LPCTSTR
  45. //
  46. //----------------------------------------------------------------------------
  47. inline LPCWSTR
  48. STRVAL(LPCWSTR lpcwsz)
  49. {
  50. return lpcwsz ? lpcwsz : EMPTYSTRING;
  51. }
  52. //+---------------------------------------------------------------------------
  53. //
  54. // Function: ADsIsEmptyString
  55. //
  56. // Synopsis: Returns TRUE if the string is empty, FALSE otherwise.
  57. //
  58. // History: 7-20-94 adams Created
  59. //
  60. //----------------------------------------------------------------------------
  61. inline BOOL
  62. ADsIsEmptyString(LPCWSTR lpcwsz)
  63. {
  64. return !(lpcwsz && lpcwsz[0]);
  65. }
  66. //+---------------------------------------------------------------------------
  67. //
  68. // Function: ADsFreeString
  69. //
  70. // Synopsis: Frees a BSTR.
  71. //
  72. // History: 5-06-94 adams Created
  73. //
  74. //----------------------------------------------------------------------------
  75. inline void
  76. ADsFreeString(BSTR bstr)
  77. {
  78. SysFreeString(bstr);
  79. }
  80. STDAPI ADsAllocString(const OLECHAR * pch, BSTR * pBSTR);
  81. STDAPI ADsAllocStringLen(const OLECHAR * pch, UINT uc, BSTR * pBSTR);
  82. STDAPI ADsReAllocString(BSTR * pBSTR, const OLECHAR * pch);
  83. STDAPI ADsReAllocStringLen(BSTR * pBSTR, const OLECHAR * pch, UINT uc);
  84. STDAPI_(UINT) ADsStringLen(BSTR bstr);
  85. #ifdef WIN32
  86. STDAPI_(unsigned int) ADsStringByteLen(BSTR bstr);
  87. STDAPI ADsAllocStringByteLen(const char * psz, unsigned int len, BSTR * pBSTR);
  88. #endif
  89. STDAPI_(int) ADsStringCmp(CBSTR bstr1, CBSTR bstr2);
  90. STDAPI_(int) ADsStringNCmp(CBSTR bstr1, CBSTR bstr2, size_t c);
  91. STDAPI_(int) ADsStringICmp(CBSTR bstr1, CBSTR bstr2);
  92. STDAPI_(int) ADsStringNICmp(CBSTR bstr1, CBSTR bstr2, size_t c);
  93. #endif // #ifndef _HXX_FBSTR