3 #include <atlsimpcoll.h>
7 [uuid("232FD5D2-4954-41E7-BF9B-09E1257B1A95")]
8 interface IDSMPropertyBag
: public IPropertyBag2
10 STDMETHOD(SetProperty
) (LPCWSTR key
, LPCWSTR value
) = 0;
11 STDMETHOD(SetProperty
) (LPCWSTR key
, VARIANT
* var
) = 0;
12 STDMETHOD(GetProperty
) (LPCWSTR key
, BSTR
* value
) = 0;
13 STDMETHOD(DelAllProperties
) () = 0;
14 STDMETHOD(DelProperty
) (LPCWSTR key
) = 0;
17 class IDSMPropertyBagImpl
: public ATL::CSimpleMap
<CStringW
, CStringW
>, public IDSMPropertyBag
, public IPropertyBag
19 BOOL
Add(const CStringW
& key
, const CStringW
& val
) {return __super::Add(key
, val
);}
20 BOOL
SetAt(const CStringW
& key
, const CStringW
& val
) {return __super::SetAt(key
, val
);}
23 IDSMPropertyBagImpl();
24 virtual ~IDSMPropertyBagImpl();
28 STDMETHODIMP
Read(LPCOLESTR pszPropName
, VARIANT
* pVar
, IErrorLog
* pErrorLog
);
29 STDMETHODIMP
Write(LPCOLESTR pszPropName
, VARIANT
* pVar
);
33 STDMETHODIMP
Read(ULONG cProperties
, PROPBAG2
* pPropBag
, IErrorLog
* pErrLog
, VARIANT
* pvarValue
, HRESULT
* phrError
);
34 STDMETHODIMP
Write(ULONG cProperties
, PROPBAG2
* pPropBag
, VARIANT
* pvarValue
);
35 STDMETHODIMP
CountProperties(ULONG
* pcProperties
);
36 STDMETHODIMP
GetPropertyInfo(ULONG iProperty
, ULONG cProperties
, PROPBAG2
* pPropBag
, ULONG
* pcProperties
);
37 STDMETHODIMP
LoadObject(LPCOLESTR pstrName
, DWORD dwHint
, IUnknown
* pUnkObject
, IErrorLog
* pErrLog
);
41 STDMETHODIMP
SetProperty(LPCWSTR key
, LPCWSTR value
);
42 STDMETHODIMP
SetProperty(LPCWSTR key
, VARIANT
* var
);
43 STDMETHODIMP
GetProperty(LPCWSTR key
, BSTR
* value
);
44 STDMETHODIMP
DelAllProperties();
45 STDMETHODIMP
DelProperty(LPCWSTR key
);
50 [uuid("EBAFBCBE-BDE0-489A-9789-05D5692E3A93")]
51 interface IDSMResourceBag
: public IUnknown
53 STDMETHOD_(DWORD
, ResGetCount
) () = 0;
54 STDMETHOD(ResGet
) (DWORD iIndex
, BSTR
* ppName
, BSTR
* ppDesc
, BSTR
* ppMime
, BYTE
** ppData
, DWORD
* pDataLen
, DWORD_PTR
* pTag
) = 0;
55 STDMETHOD(ResSet
) (DWORD iIndex
, LPCWSTR pName
, LPCWSTR pDesc
, LPCWSTR pMime
, BYTE
* pData
, DWORD len
, DWORD_PTR tag
) = 0;
56 STDMETHOD(ResAppend
) (LPCWSTR pName
, LPCWSTR pDesc
, LPCWSTR pMime
, BYTE
* pData
, DWORD len
, DWORD_PTR tag
) = 0;
57 STDMETHOD(ResRemoveAt
) (DWORD iIndex
) = 0;
58 STDMETHOD(ResRemoveAll
) (DWORD_PTR tag
) = 0;
65 CStringW name
, desc
, mime
;
68 CDSMResource(const CDSMResource
& r
);
69 CDSMResource(LPCWSTR name
, LPCWSTR desc
, LPCWSTR mime
, BYTE
* pData
, int len
, DWORD_PTR tag
= 0);
70 virtual ~CDSMResource();
71 void operator = (const CDSMResource
& r
);
73 // global access to all resources
74 static CCritSec m_csResources
;
75 static CAtlMap
<DWORD
, CDSMResource
*> m_resources
;
78 class IDSMResourceBagImpl
: public IDSMResourceBag
81 CAtlArray
<CDSMResource
> m_resources
;
84 IDSMResourceBagImpl();
86 void operator += (const CDSMResource
& r
) {m_resources
.Add(r
);}
90 STDMETHODIMP_(DWORD
) ResGetCount();
91 STDMETHODIMP
ResGet(DWORD iIndex
, BSTR
* ppName
, BSTR
* ppDesc
, BSTR
* ppMime
, BYTE
** ppData
, DWORD
* pDataLen
, DWORD_PTR
* pTag
= NULL
);
92 STDMETHODIMP
ResSet(DWORD iIndex
, LPCWSTR pName
, LPCWSTR pDesc
, LPCWSTR pMime
, BYTE
* pData
, DWORD len
, DWORD_PTR tag
= 0);
93 STDMETHODIMP
ResAppend(LPCWSTR pName
, LPCWSTR pDesc
, LPCWSTR pMime
, BYTE
* pData
, DWORD len
, DWORD_PTR tag
= 0);
94 STDMETHODIMP
ResRemoveAt(DWORD iIndex
);
95 STDMETHODIMP
ResRemoveAll(DWORD_PTR tag
= 0);
100 [uuid("2D0EBE73-BA82-4E90-859B-C7C48ED3650F")]
101 interface IDSMChapterBag
: public IUnknown
103 STDMETHOD_(DWORD
, ChapGetCount
) () = 0;
104 STDMETHOD(ChapGet
) (DWORD iIndex
, REFERENCE_TIME
* prt
, BSTR
* ppName
) = 0;
105 STDMETHOD(ChapSet
) (DWORD iIndex
, REFERENCE_TIME rt
, LPCWSTR pName
) = 0;
106 STDMETHOD(ChapAppend
) (REFERENCE_TIME rt
, LPCWSTR pName
) = 0;
107 STDMETHOD(ChapRemoveAt
) (DWORD iIndex
) = 0;
108 STDMETHOD(ChapRemoveAll
) () = 0;
109 STDMETHOD_(long, ChapLookup
) (REFERENCE_TIME
* prt
, BSTR
* ppName
) = 0;
110 STDMETHOD(ChapSort
) () = 0;
122 CDSMChapter(REFERENCE_TIME rt
, LPCWSTR name
);
123 void operator = (const CDSMChapter
& c
);
124 static int Compare(const void* a
, const void* b
);
127 class IDSMChapterBagImpl
: public IDSMChapterBag
130 CAtlArray
<CDSMChapter
> m_chapters
;
134 IDSMChapterBagImpl();
136 void operator += (const CDSMChapter
& c
) {m_chapters
.Add(c
); m_fSorted
= false;}
140 STDMETHODIMP_(DWORD
) ChapGetCount();
141 STDMETHODIMP
ChapGet(DWORD iIndex
, REFERENCE_TIME
* prt
, BSTR
* ppName
= NULL
);
142 STDMETHODIMP
ChapSet(DWORD iIndex
, REFERENCE_TIME rt
, LPCWSTR pName
);
143 STDMETHODIMP
ChapAppend(REFERENCE_TIME rt
, LPCWSTR pName
);
144 STDMETHODIMP
ChapRemoveAt(DWORD iIndex
);
145 STDMETHODIMP
ChapRemoveAll();
146 STDMETHODIMP_(long) ChapLookup(REFERENCE_TIME
* prt
, BSTR
* ppName
= NULL
);
147 STDMETHODIMP
ChapSort();
150 class CDSMChapterBag
: public CUnknown
, public IDSMChapterBagImpl
153 CDSMChapterBag(LPUNKNOWN pUnk
, HRESULT
* phr
);
156 STDMETHODIMP
NonDelegatingQueryInterface(REFIID riid
, void** ppv
);
160 int range_bsearch(const CAtlArray
<T
>& array
, REFERENCE_TIME rt
)
162 int i
= 0, j
= array
.GetCount() - 1, ret
= -1;
163 if(j
>= 0 && rt
>= array
[j
].rt
) return j
;
166 int mid
= (i
+ j
) >> 1;
167 REFERENCE_TIME midrt
= array
[mid
].rt
;
168 if(rt
== midrt
) {ret
= mid
; break;}
169 else if(rt
< midrt
) {ret
= -1; if(j
== mid
) mid
--; j
= mid
;}
170 else if(rt
> midrt
) {ret
= mid
; if(i
== mid
) mid
++; i
= mid
;}