-
Notifications
You must be signed in to change notification settings - Fork 23
/
CIncludeDirectoryCollection.h
72 lines (62 loc) · 1.77 KB
/
CIncludeDirectoryCollection.h
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
#pragma once
#ifdef SPASM_NG_ENABLE_COM
struct _CopyVariantFromAdaptBstr {
static HRESULT copy(VARIANT* p1, const CAdapt<CComBSTR>* p2) {
p1->vt = VT_BSTR;
p1->bstrVal = p2->m_T.Copy();
return (p1->bstrVal ? S_OK : E_OUTOFMEMORY);
}
static void init(VARIANT* p) { VariantInit(p); }
static void destroy(VARIANT* p) { VariantClear(p); }
};
typedef CComEnumOnSTL<IEnumVARIANT, &IID_IEnumVARIANT, VARIANT,
_CopyVariantFromAdaptBstr,
std::vector< CAdapt<CComBSTR> > >
CComEnumVariantOnVectorOfAdaptBstr;
struct _CopyBstrFromAdaptBstr {
static HRESULT copy(BSTR* p1, const CAdapt<CComBSTR>* p2) {
*p1 = SysAllocString(p2->m_T);
return (p1 ? S_OK : E_OUTOFMEMORY);
}
static void init(BSTR* p) { }
static void destroy(BSTR* p) { SysFreeString(*p); }
};
typedef ICollectionOnSTLImpl<IDispatchImpl<IIncludeDirectoryCollection, &__uuidof(IIncludeDirectoryCollection), &LIBID_SPASM, 1, 2>,
std::vector< CAdapt<CComBSTR> >,
BSTR,
_CopyBstrFromAdaptBstr,
CComEnumVariantOnVectorOfAdaptBstr>
IIncludeDirectoryCollectionImpl;
class ATL_NO_VTABLE CIncludeDirectoryCollection :
public CComObjectRootEx<CComObjectThreadModel>,
public IIncludeDirectoryCollectionImpl
{
public:
BEGIN_COM_MAP(CIncludeDirectoryCollection)
COM_INTERFACE_ENTRY(IIncludeDirectoryCollection)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
STDMETHOD(Add)(BSTR bstrDirectory)
{
m_coll.push_back(CAdapt< CComBSTR >(bstrDirectory));
return S_OK;
}
STDMETHOD(Remove)(BSTR bstrDirectory)
{
for (auto it = m_coll.begin(); it != m_coll.end(); it++)
{
if (wcscmp((*it).m_T, bstrDirectory) == 0)
{
m_coll.erase(it);
return S_OK;
}
}
return S_FALSE;
}
STDMETHOD(Clear)()
{
m_coll.clear();
return S_OK;
}
};
#endif