8#if !defined(OCF_OLEUTIL_H)
12#if defined(BI_HAS_PRAGMA_ONCE)
25# define _ICLASS _OCFCLASS
28#define _IFUNC STDMETHODCALLTYPE
52 TBSTR(BSTR p) : P(p) {}
55 ~TBSTR(){ ::SysFreeString(P); }
60 BSTR operator =(BSTR p) { ::SysFreeString(P);
return P = p; }
61 TBSTR& operator =(
const TBSTR& p){::SysFreeString(P); P = p.
P;
return *
this;}
62 operator BSTR() {
return P;}
63 operator BSTR*() {
if(P) ::SysFreeString(P);
return &P;}
64 int operator !()
const {
return P==0;}
65 void operator ~() { ::SysFreeString(P); P = 0; }
74 void*
operator new(size_t) {
return 0;}
75 void operator delete(
void*) {}
84 static HRESULT SafeArrayGetVartype(SAFEARRAY * psa, VARTYPE * pvt);
90 return ::SafeArrayGetVartype(psa,pvt);
111 void*
Alloc(
unsigned long size);
112 void Free(
void * pv);
121# if defined(BI_COMP_BORLANDC)
127 OLECALL(OleInitialize(mem),
_T(
"OleInitialize"));
128 OLECALL(CoGetMalloc(MEMCTX_TASK, &
Mem),
_T(
"CoGetMalloc"));
136 OLECALL(CoGetMalloc(MEMCTX_TASK, &
Mem),
_T(
"CoGetMalloc"));
181 TClassId(
const GUID & guid,
int offset);
216TClassId::operator GUID&()
254void CmpGuid12 (IUnknown* This, REFIID req, REFIID ref,
void** pif);
255void CmpGuidOle(IUnknown* This, REFIID req,
void** pif);
266 operator IUnknown&() {
return *Outer;}
267 operator IUnknown*() {Outer->AddRef();
return Outer;}
268 IUnknown* SetOuter(IUnknown* outer = 0);
270 unsigned long GetRefCount();
271 unsigned long AdjustRefCount(
int i);
272 IUnknown& Aggregate(
TUnknown& inner);
280 virtual HRESULT QueryObject(
const GUID&
iid,
void** pif);
283 class _ICLASS TUnknownI :
public IUnknown {
285 HRESULT
_IFUNC QueryInterface(
const GUID &
iid,
void** pif);
286 unsigned long _IFUNC AddRef();
287 unsigned long _IFUNC Release();
288 TUnknownI() : RefCnt(0), Inner(0) {}
295 friend class TUnknownI;
309inline TUnknown& TUnknown::TUnknownI::Host()
316 return (
unsigned long)(I.RefCnt += i);
318# if defined(BI_COMP_BORLANDC)
367#define COMBASES_D(cls, bases) \
368 class cls : public TUnknown, bases { \
370 virtual HRESULT _IFUNC QueryInterface(const GUID & iid, void ** pif); \
371 virtual unsigned long _IFUNC AddRef(); \
372 virtual unsigned long _IFUNC Release(); \
373 virtual HRESULT QueryObject(const GUID & iid, void ** pif); \
374 HRESULT QueryBases(const GUID & iid, void ** pif) \
375 {return cls::QueryObject(iid, pif);} \
378#define COMQRY1BASES(i1) public i1
379#define COMQRY2BASES(i1,i2) public i1, COMQRY1BASES(i2)
380#define COMQRY3BASES(i1,i2,i3) public i1, COMQRY2BASES(i2,i3)
381#define COMQRY4BASES(i1,i2,i3,i4) public i1, COMQRY3BASES(i2,i3,i4)
382#define COMQRY5BASES(i1,i2,i3,i4,i5) public i1, COMQRY4BASES(i2,i3,i4,i5)
384#define DECLARE_COMBASES1(cls,i1) \
385 COMBASES_D(cls,COMQRY1BASES(i1))
386#define DECLARE_COMBASES2(cls,i1,i2) \
387 COMBASES_D(cls,COMQRY2BASES(i1,i2))
388#define DECLARE_COMBASES3(cls,i1,i2,i3) \
389 COMBASES_D(cls,COMQRY3BASES(i1,i2,i3))
390#define DECLARE_COMBASES4(cls,i1,i2,i3,i4) \
391 COMBASES_D(cls,COMQRY4BASES(i1,i2,i3,i4))
392#define DECLARE_COMBASES5(cls,i1,i2,i3,i4,i5) \
393 COMBASES_D(cls,COMQRY5BASES(i1,i2,i3,i4,i5))
398#define TUNKNOWN_STANDARD_IUNKNOWN_METHODS \
399 owl::ulong _IFUNC AddRef() {return GetOuter()->AddRef();} \
400 owl::ulong _IFUNC Release() {return GetOuter()->Release();} \
401 HRESULT _IFUNC QueryInterface(const GUID& iid, void** iface) \
402 {return GetOuter()->QueryInterface(iid, iface);}
408#define IUNKNOWN_FORWARD(cls, outer) \
409 HRESULT _IFUNC cls::QueryInterface(const GUID & iid, void * * pif)\
410 { return outer->QueryInterface(iid, pif); } \
411 owl::ulong _IFUNC cls::AddRef() { return outer->AddRef(); } \
412 owl::ulong _IFUNC cls::Release() { return outer->Release(); }
414#define COMBASES_I(cls, tests) \
415 IUNKNOWN_FORWARD(cls, Outer) \
416 HRESULT cls::QueryObject(const GUID & iid, void ** pif) \
417 { *pif = 0; tests return ResultFromScode(E_NOINTERFACE); }
419#define COMBASEQUERY(cls) \
420 cls##_QueryInterface(this,iid,pif); if(*pif) return NOERROR;
422#define COMQRY1TEST(i1) COMBASEQUERY(i1)
423#define COMQRY2TEST(i1,i2) COMBASEQUERY(i1) COMQRY1TEST(i2)
424#define COMQRY3TEST(i1,i2,i3) COMBASEQUERY(i1) COMQRY2TEST(i2,i3)
425#define COMQRY4TEST(i1,i2,i3,i4) COMBASEQUERY(i1) COMQRY3TEST(i2,i3,i4)
426#define COMQRY5TEST(i1,i2,i3,i4,i5) COMBASEQUERY(i1) COMQRY3TEST(i2,i3,i4,i5)
428#define DEFINE_COMBASES1(cls,i1) \
429 COMBASES_I(cls,COMQRY1TEST(i1))
430#define DEFINE_COMBASES2(cls,i1,i2) \
431 COMBASES_I(cls,COMQRY2TEST(i1,i2))
432#define DEFINE_COMBASES3(cls,i1,i2,i3) \
433 COMBASES_I(cls,COMQRY3TEST(i1,i2,i3))
434#define DEFINE_COMBASES4(cls,i1,i2,i3,i4) \
435 COMBASES_I(cls,COMQRY4TEST(i1,i2,i3,i4))
436#define DEFINE_COMBASES5(cls,i1,i2,i3,i4,i5) \
437 COMBASES_I(cls,COMQRY5TEST(i1,i2,i3,i4,i5))
439#define DEFINE_QI_BASE(cls, low) \
440 inline void cls##_QueryInterface(cls* obj, REFIID iid, void * * pif) \
441 {if (iid.Data1==low) CmpGuid12(obj, iid, IID_##cls, pif);}
443#define DEFINE_QI_OLEBASE(cls, low) \
444 inline void cls##_QueryInterface(cls* obj, REFIID iid, void * * pif) \
445 {if (iid.Data1==low) CmpGuidOle(obj, iid, pif);}
447#define DEFINE_QI_DERIVED(cls, base, low) \
448 inline void cls##_QueryInterface(cls* obj, REFIID iid, void * * pif) \
449 {if (iid.Data1==low) CmpGuid12(obj, iid, IID_##cls, pif); \
450 else base##_QueryInterface(obj, iid, pif);}
452#define DEFINE_QI_OLEDERIVED(cls, base, low) \
453 inline void cls##_QueryInterface(cls* obj, REFIID iid, void * * pif) \
454 {if (iid.Data1==low) CmpGuidOle(obj, iid, pif); \
455 else base##_QueryInterface(obj, iid, pif);}
457#define DEFINE_QI_DELEGATE(cls, member) \
458 inline void cls##_QueryInterface(cls* obj, REFIID iid, void * * pif) \
459 {obj->member->QueryInterface(iid, pif);}
461#define DEFINE_QI_DELEGATE_TEST(cls, member) \
462 inline void cls##_QueryInterface(cls* obj, REFIID iid, void * * pif) \
463 {if (obj->member) obj->member->QueryInterface(iid, pif);}
465#define DEFINE_QI_MEMBER(name, member) \
466 void name##_QueryInterface(void *, REFIID iid, void * * pif) \
467 {member->QueryInterface(iid, pif);}
469#define DEFINE_QI_MEMBER_TEST(name, member) \
470 void name##_QueryInterface(void *, REFIID iid, void * * pif) \
471 {if (member) member->QueryInterface(iid, pif);}
473#define DEFINE_COMBASE_DELEGATE(cls, ifc, member) \
474 struct _ICLASS cls { \
475 cls() : member(0) {} \
477 DEFINE_QI_MEMBER_TEST(cls, member) \
Base GUID for a components sequence of GUIDs.
int GetOffset(const GUID &guid)
TClassId operator[](int offset)
TBaseClassId(owl::TRegList ®Info, int maxAlloc=256)
GUID/IID/CLSID management.
TClassId & operator=(const TClassId ©)
TClassId()
Default constructor - Derived class must set GUID.
Object to initialize OLE and access memory manager.
void * Alloc(unsigned long size)
static HRESULT SafeArrayGetVartype(SAFEARRAY *psa, VARTYPE *pvt)
Simple wrapper of TOleAllocator used exclusively for initializing OLE.
Standard implementation of a controlling IUnknown for an object, to be inherited with other COM inter...
IUnknown * SetOuter(IUnknown *outer=0)
unsigned long AdjustRefCount(int i)
A registration parameter table, composed of a list of TRegItems.
System string (BSTR) encapsulation.
Object Component Framework (COM encapsulation)
void OcHiMetricToPixel(const SIZEL &sizeHM, SIZEL &sizePix)
void CmpGuidOle(IUnknown *This, REFIID req, void **pif)
owl::TSysStr TBSTR
BASIC global string encapsulation.
void CmpGuid12(IUnknown *This, REFIID req, REFIID ref, void **pif)
void OcPixelToHiMetric(const SIZEL &sizePix, SIZEL &sizeHM)
Object Windows Library (OWLNext Core)
ObjectComponents fundamental definitions.
#define OLECALL(func, msg)
Various types of smart pointer templatized classes.
Definition of class TString, a flexible universal string envelope class.