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.

75 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 <types.hxx>
  30. #include <safepnt.hxx>
  31. //+-------------------------------------------------------------------------
  32. //
  33. // Macro: DefineSmartItfP
  34. //
  35. // Purpose: Macro to define smart pointer to an IUnknown derivative.
  36. //
  37. // Notes: The smart pointer so defined has a fixed name consisting of
  38. // X (for eXception-safe) prefixed to the name of the pointed-to
  39. // class. If you want to choose the name, you should use the
  40. // SAFE_INTERFACE_PTR macro in safepnt.hxx.
  41. //
  42. //--------------------------------------------------------------------------
  43. #define DefineSmartItfP(cls) SAFE_INTERFACE_PTR(X##cls,cls)
  44. DefineSmartItfP(IUnknown)
  45. // For backwards compatibility
  46. #define DefineSmartP(cls) DefineSmartItfP(cls)
  47. //+-------------------------------------------------------------------------
  48. //
  49. // Macro: DefineSmartMemP
  50. //
  51. // Purpose: Macro to define smart pointer to any MemAlloc'ed structure
  52. //
  53. // Notes: This macro is used to define a smart pointer to any structure
  54. // allocated using MemAlloc. Invocation is as follows:
  55. //
  56. // DefineSmartMemP(SWCStringArray,arrow_spec)
  57. //
  58. // where arrow_spec is DEFINE_ARROW if the pointed-to type
  59. // supports a member-of (->) operator, and NO_ARROW if
  60. // it does not. (EG: use NO_ARROW for WCString).
  61. //
  62. //--------------------------------------------------------------------------
  63. #define _MEM_DEFINE_ARROW(cls) SAFE_MEMALLOC_PTR(X##cls,cls)
  64. #define _MEM_NO_ARROW(cls) SAFE_MEMALLOC_MEMPTR(X##cls,cls)
  65. #define DefineSmartMemP(cls,arrow) _MEM_##arrow(cls)
  66. #endif // of ifndef __SMARTP_HXX__