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.

74 lines
2.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation.
  4. //
  5. // File: smartp.hxx
  6. //
  7. // Contents: Class and associated macros for generic smart pointer
  8. // capability.
  9. //
  10. // Classes: XIUnknown
  11. // XMem
  12. //
  13. // History: 30-Mar-92 MikeSe Created
  14. // 6-Oct-92 MikeSe Added XMem and related macros.
  15. //
  16. // Notes: All of the interesting stuff from here is now in safepnt.hxx
  17. // which should be used in preference. The following correspondences
  18. // exist between the macros defined here and those in safepnt,
  19. // should you wish to convert to avoid the (deliberately) annoying
  20. // warning:
  21. //
  22. // DefineSmartItfP(class) == SAFE_INTERFACE_PTR(Xclass,class)
  23. // DefineSmartMemP(class,NO_ARROW) == SAFE_MEMALLOC_MEMPTR(Xclass,class)
  24. // DefineSmartMemP(class,DEFINE_ARROW) == SAFE_MEMALLOC_PTR(Xclass,class)
  25. //
  26. //----------------------------------------------------------------------------
  27. #ifndef __SMARTP_HXX__
  28. #define __SMARTP_HXX__
  29. #include <safepnt.hxx>
  30. //+-------------------------------------------------------------------------
  31. //
  32. // Macro: DefineSmartItfP
  33. //
  34. // Purpose: Macro to define smart pointer to an IUnknown derivative.
  35. //
  36. // Notes: The smart pointer so defined has a fixed name consisting of
  37. // X (for eXception-safe) prefixed to the name of the pointed-to
  38. // class. If you want to choose the name, you should use the
  39. // SAFE_INTERFACE_PTR macro in safepnt.hxx.
  40. //
  41. //--------------------------------------------------------------------------
  42. #define DefineSmartItfP(cls) SAFE_INTERFACE_PTR(X##cls,cls)
  43. DefineSmartItfP(IUnknown)
  44. // For backwards compatibility
  45. #define DefineSmartP(cls) DefineSmartItfP(cls)
  46. //+-------------------------------------------------------------------------
  47. //
  48. // Macro: DefineSmartMemP
  49. //
  50. // Purpose: Macro to define smart pointer to any MemAlloc'ed structure
  51. //
  52. // Notes: This macro is used to define a smart pointer to any structure
  53. // allocated using MemAlloc. Invocation is as follows:
  54. //
  55. // DefineSmartMemP(SWCStringArray,arrow_spec)
  56. //
  57. // where arrow_spec is DEFINE_ARROW if the pointed-to type
  58. // supports a member-of (->) operator, and NO_ARROW if
  59. // it does not. (EG: use NO_ARROW for WCString).
  60. //
  61. //--------------------------------------------------------------------------
  62. #define _MEM_DEFINE_ARROW(cls) SAFE_MEMALLOC_PTR(X##cls,cls)
  63. #define _MEM_NO_ARROW(cls) SAFE_MEMALLOC_MEMPTR(X##cls,cls)
  64. #define DefineSmartMemP(cls,arrow) _MEM_##arrow(cls)
  65. #endif // of ifndef __SMARTP_HXX__