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