/trunk/source/Tools/JLevelViewer/class.h
C Header | 904 lines | 743 code | 108 blank | 53 comment | 98 complexity | 4bbb7c9235f2cb46e31abf7831d055e9 MD5 | raw file
- //////////////////////////////////////////////////////////////////////////
- //
- // PROJECT:
- // FILE: class.h - base class object model definitions
- // AUTHOR: Vladimir Gumenuk
- // CREATED: 14-Aug-2004
- //
- // MODIFIED: 5-Jul-2005 added IClassEnum, IClassCollection
- //
- //////////////////////////////////////////////////////////////////////////
-
- #ifndef __class_h__
- #define __class_h__
-
- #pragma warning(disable:4311) // 'type cast' : pointer truncation from 'void *' to 'uint
- #pragma warning(disable:4312) // 'type cast' : conversion from 'uint' to 'IClassUnknown *' of greater size
- #pragma warning(disable:4267) // '=' : conversion from 'size_t' to 'dword', possible loss of data
-
- #include <assert.h>
- #include <string.h>
- #include <memory.h>
-
- #define interface struct
-
- //////////////////////////////////////////////////////////////////////////
- // typedefs
- typedef unsigned char byte;
- typedef byte* lpbyte;
- typedef unsigned int uint;
- typedef unsigned short word;
- typedef unsigned long dword;
- typedef unsigned long ulong;
- typedef float real;
- typedef double vtime;
-
- typedef char* lpstr;
- typedef const char* lpcstr;
- typedef unsigned short wchar;
- typedef wchar* lpwstr;
- typedef const lpwstr lpcwstr;
-
- #ifdef CLS_UNICODE
- typedef wchar tchar;
- typedef lpwstr lptstr;
- typedef lpcwstr lpctstr;
- #else // ANSI
- typedef char tchar;
- typedef lpstr lptstr;
- typedef lpcstr lpctstr;
- #endif // CLS_UNICODE
-
- typedef lptstr bstr; // special string
-
- typedef uint ciid; // class interface id
-
- typedef int vresult; // virtual method result
-
- // this class id reserved for IClassUnknown interface
- #define CID_IClassUnknown 0x00000001
- // this class id reserved for IClassEnum interface
- #define CID_IClassEnum 0x00000002
- // this class id reserved for IClassCollection interface
- #define CID_IClassCollection 0x00000003
- // this class id reserved for IClassStream
- #define CID_IClassStream 0x00000004
-
-
- #define VIRTUAL =0
- #define DEFFN(n) virtual vresult n
- #define DEFFN_(r,n) virtual r n
- #define STDEFFN(n) virtual vresult __stdcall n
- #define STDEFFN_(r,n) virtual r __stdcall n
-
- //////////////////////////////////////////////////////////////////////////
- // Base class for all com classes
- class IClassUnknown
- {
- public:
- virtual bool QueryClass( ciid iid, void **ppv ) = 0;
- virtual uint AddRef() = 0;
- virtual uint Release() = 0;
- };
-
- //////////////////////////////////////////////////////////////////////////
- // enumerator
- class IClassEnum : public IClassUnknown
- {
- public:
- virtual void Reset() = 0;
- virtual bool get_Next( IClassUnknown **ppv ) = 0;
- };
-
- //////////////////////////////////////////////////////////////////////////
- // collection
- class IClassCollection : public IClassUnknown
- {
- public:
- virtual uint get_Count() = 0;
- virtual bool get_Item( uint idx, IClassUnknown **ppv ) = 0;
- virtual bool get_Enum( IClassEnum **ppv ) = 0;
- };
-
-
- //////////////////////////////////////////////////////////////////////////
- // Stream
-
- class IClassStream : public IClassUnknown
- {
- public:
- // returns the current size of the stream
- virtual dword get_Size() = 0;
- // Reads the requested size from stream, returns the number of bytes,
- // that were actually read. Advance stream pointer
- virtual dword Read( void *pBuf, dword Size ) = 0;
- // Writes the specified number of bytes to stram, returns the number of bytes,
- // that were actually written
- virtual dword Write( void *pBuf, dword Size ) = 0;
- // Changes the position of the internal pointer, returns the new position
- virtual dword Seek( long Offset ) = 0;
- };
-
-
- //////////////////////////////////////////////////////////////////////////
- // base templates
-
- #define NOVTABLE __declspec(novtable)
-
- // compiler dependent
- #define cls_packing 8
- #define classoffset(base, derived) ((uint)(static_cast<base*>((derived*)cls_packing))-cls_packing)
-
- typedef struct
- {
- ciid iid;
- uint offset;
- } vtbl_entry_t;
-
- inline bool _QueryClass( void *pThis, const vtbl_entry_t *pClasses, ciid iid, void **ppOut ) {
- if( pClasses->iid == 1 /*CID_IClassUnknown*/ ) {
- IClassUnknown *p = (IClassUnknown*)((uint)pThis + pClasses->offset);
- *ppOut = p;
- return true;
- }
- while( pClasses->iid != 0 ) {
- if( pClasses->iid == iid ) {
- IClassUnknown *p = (IClassUnknown*)((uint)pThis + pClasses->offset);
- *ppOut = p;
- return true;
- }
- pClasses++;
- }
- return false;
- };
-
- #define BEGIN_CLASS_MAP(c) \
- public: \
- typedef c _MapClass; \
- bool _QueryClassInternal( ciid iid, void **ppv ) { \
- return _QueryClass( this, _get_classes(), iid, ppv ); } \
- const static vtbl_entry_t * __stdcall _get_classes() { \
- static const vtbl_entry_t _classes[] = {
-
- #define CLASS_ENTRY(i) \
- { CID_##i, classoffset(i,_MapClass) },
-
- #define END_CLASS_MAP() \
- { 0, 0 } }; return _classes; } \
- virtual bool QueryClass( ciid iid, void **ppv ) = 0; \
- virtual uint AddRef() = 0; \
- virtual uint Release() = 0; \
-
-
- class CClassObjectRoot
- {
- public:
- void SetVoid( void *lpVoid ) { ; }
- bool FinalConstruct() { return true; } // with declaration specificator novtable impossible call virtual functions
- void FinalRelease() { ; } // from constructor,this should help...
- };
-
- //////////////////////////////////////////////////////////////////////////
- // last object in hierarchy
- template<class T>
- class CClassCreator : public T
- {
- typedef T _clsBase;
- uint m_cRef;
- public:
-
- CClassCreator() { m_cRef = 0; }
- virtual ~CClassCreator() { assert( m_cRef == 0 ); }
-
- bool QueryClass( ciid iid, void **ppv ) {
- if( ppv && _QueryClassInternal( iid, ppv ) ) {
- AddRef();
- return true;
- }
- return false;
- }
-
- uint AddRef() { return ++m_cRef; }
-
- uint Release() {
- if( --m_cRef == 0 ) {
- FinalRelease();
- delete this;
- return 0;
- }
- return m_cRef;
- }
-
- static bool _create( CClassCreator<T> **ppv ) {
- if( !ppv ) return false;
- CClassCreator<T> *p = new CClassCreator<T>();
- if( !p )
- return false;
- p->SetVoid( 0 );
- if( !p->FinalConstruct() ) {
- delete p;
- return false;
- }
- *ppv = p;
- return true;
- }
-
- static bool _create_vp( void *lpVoid, CClassCreator<T> **ppv ) {
- if( !ppv ) return false;
- CClassCreator<T> *p = new CClassCreator<T>();
- if( !p )
- return false;
- p->SetVoid( lpVoid );
- if( !p->FinalConstruct() ) {
- delete p;
- return false;
- }
- *ppv = p;
- return true;
- }
- };
-
- //////////////////////////////////////////////////////////////////////////
- // Helpers
-
- //////////////////////////////////////////////////////////////////////////
- template <class T>
- class _NoAddRefReleasePtr : public T
- {
- private:
- virtual uint AddRef() = 0;
- virtual uint Release() = 0;
- };
-
- inline IClassUnknown* ClassPtrAssign( IClassUnknown** pp, IClassUnknown* lp ) {
- if( lp != 0 )
- lp->AddRef();
- if( *pp )
- ( *pp )->Release();
- *pp = lp;
- return lp;
- }
-
- template <class T>
- class CSafePtr
- {
- public:
- typedef T _PtrClass;
- T* p;
-
- CSafePtr() {
- p=0;
- }
- CSafePtr( T* lp ) {
- if( (p = lp) != 0 )
- p->AddRef();
- }
- CSafePtr( const CSafePtr<T>& lp ) {
- if( (p = lp.p) != 0 )
- p->AddRef();
- }
- ~CSafePtr() {
- if( p )
- p->Release();
- }
- void Release() {
- IClassUnknown* pTemp = p;
- if( pTemp ) {
- p = 0;
- pTemp->Release();
- }
- }
- inline operator T*() const {
- return (T*)p;
- }
- inline T& operator*() const { assert(p!=0);
- return *p;
- }
- inline T** operator&() { assert(p==0);
- return &p;
- }
- inline _NoAddRefReleasePtr<T>* operator->() const { assert(p!=0);
- return (_NoAddRefReleasePtr<T>*)p;
- }
- inline T* operator=( T* lp ) {
- return (T*)ClassPtrAssign( (IClassUnknown**)&p, lp );
- }
- inline T* operator=( const CSafePtr<T>& lp ) {
- return (T*)ClassPtrAssign( (IClassUnknown**)&p, lp.p );
- }
- inline bool operator!() const {
- return (p == 0);
- }
- inline bool operator< ( T* pT ) const {
- return p < pT;
- }
- inline bool operator==( T* pT ) const {
- return p == pT;
- }
- inline void Attach(T* p2) {
- if( p )
- p->Release();
- p = p2;
- }
- inline T* Detach() {
- T* pt = p;
- p = 0;
- return pt;
- }
- bool CopyTo( T** ppT ) {
- assert(ppT != 0);
- if( ppT == 0 )
- return false;
- *ppT = p;
- if( p )
- p->AddRef();
- return true;
- }
- };
-
-
- //////////////////////////////////////////////////////////////////////////
- // safe memory buffer
- template <class T>
- class CMemPtr
- {
- public:
- CMemPtr() { p = 0; cb = 0; }
- CMemPtr( dword dwSize ) { Alloc( dwSize ); }
- ~CMemPtr() { if( p ) delete[] p; }
-
- bool Alloc( dword dwSize, bool bZero = false ) {
- if( dwSize ) {
- cb = dwSize;
- p = new T[cb];
- if( p ) {
- if( bZero ) {
- dword dwByteLen = cb * sizeof(T);
- lpbyte pBuffer = (lpbyte)p;
- for( register dword i = 0; i < dwByteLen; i++ ) p[i] = 0;
- }
- return true;
- }
- }
- return false;
- }
-
- inline void Free() { if( p ) { delete[] p; p = 0; cb = 0; } }
-
- inline dword Size() const { return cb; }
-
- inline operator T() const {
- return p;
- }
-
- inline operator T*() const {
- return &p[0];
- }
-
- inline T* operator& () {
- return p;
- }
-
- inline T operator[] ( dword dwIndex ) const {
- return p[dwIndex];
- }
-
- T *p;
- dword cb;
- };
-
-
- //////////////////////////////////////////////////////////////////////////
- template<class T>
- class CClassPtrArray
- {
- typedef T* LPT;
- LPT *m_pT;
- uint m_iCount;
- uint m_iAllocated;
-
- public:
- CClassPtrArray() {
- m_pT = 0; m_iCount = 0; m_iAllocated = 0;
- }
-
- ~CClassPtrArray() {
- Clear();
- }
-
- inline uint GetSize() {
- return m_iCount;
- }
-
- void Clear() {
- if( m_pT ) {
- for( uint i = 0; i < m_iCount; i++ ) {
- m_pT[i]->Release();
- }
- delete[] m_pT;
- m_pT = 0; m_iCount = 0; m_iAllocated = 0;
- }
- }
-
- void Add( T* t ) {
- if( m_iCount == m_iAllocated ) {
- uint iNewAllocSize = (m_iAllocated == 0) ? 1 : ( m_iCount * 2 );
- m_iAllocated = iNewAllocSize;
- LPT *p = new LPT[ iNewAllocSize ];
- for( uint i = 0; i < m_iCount; i++ )
- p[i] = m_pT[i];
- if( m_pT )
- delete[] m_pT;
- m_pT = p;
- }
- m_pT[m_iCount] = t;
- m_pT[m_iCount]->AddRef();
- m_iCount++;
- }
-
- void Remove( uint idx ) {
- if( idx < m_iCount ) {
- m_pT[idx]->Release();
- m_pT[idx] = 0;
- uint i = idx + 1;
- while( idx < m_iCount ) {
- m_pT[idx++] = m_pT[i++];
- }
- m_iCount--;
- }
- }
-
- inline T*& operator[] ( uint index ) const {
- return m_pT[index];
- }
-
- CClassPtrArray<T>& operator= ( const CClassPtrArray<T>& a ) {
- Clear();
- if( a.m_pT && a.m_iCount ) {
- m_iAllocated = a.m_iAllocated;
- m_iCount = a.m_iCount;
- m_pT = new LPT[ m_iAllocated ];
- for( uint i = 0; i < m_iCount; i++ ) {
- m_pT[i] = a.m_pT[i];
- m_pT[i]->AddRef();
- }
- }
- return *this;
- }
- };
-
- //////////////////////////////////////////////////////////////////////////
- //
- #define GROWLEN 4
-
- class CDynamicClsUnkArray
- {
- public:
- CDynamicClsUnkArray() {
- m_nSize = 0;
- m_ppUnk = NULL;
- }
-
- ~CDynamicClsUnkArray() {
- if( m_nSize > 1 )
- free( m_ppUnk );
- }
-
- DWORD Add( IClassUnknown *pUnk ) {
- IClassUnknown** pp = NULL;
- if( m_nSize == 0 ) {// no connections
- m_pUnk = pUnk;
- m_nSize = 1;
- return (DWORD)m_pUnk;
- } else if ( m_nSize == 1 ) {
- //create array
- pp = (IClassUnknown**)malloc(sizeof(IClassUnknown*)*GROWLEN);
- if (pp == NULL)
- return 0;
- memset(pp, 0, sizeof(IClassUnknown*)*GROWLEN);
- *pp = m_pUnk;
- m_ppUnk = pp;
- m_nSize = GROWLEN;
- }
- for( pp = begin(); pp<end(); pp++ ) {
- if( *pp == NULL ) {
- *pp = pUnk;
- return (DWORD)pUnk;
- }
- }
- int nAlloc = m_nSize*2;
- pp = (IClassUnknown**)realloc( m_ppUnk, sizeof(IClassUnknown*)*nAlloc );
- if( pp == NULL )
- return 0;
- m_ppUnk = pp;
- memset( &m_ppUnk[m_nSize], 0, sizeof(IClassUnknown*)*m_nSize );
- m_ppUnk[m_nSize] = pUnk;
- m_nSize = nAlloc;
- return (DWORD)pUnk;
- }
-
- BOOL Remove( DWORD dwCookie ) {
- IClassUnknown** pp;
- if( dwCookie == NULL || m_nSize == 0 )
- return FALSE;
- if( m_nSize == 1 ) {
- if( (DWORD)m_pUnk == dwCookie ) {
- m_nSize = 0;
- return TRUE;
- }
- return FALSE;
- }
- for( pp = begin(); pp < end(); pp++ ) {
- if( (DWORD)*pp == dwCookie ) {
- *pp = NULL;
- return TRUE;
- }
- }
- return FALSE;
- }
-
- static DWORD GetCookie( IClassUnknown **pp ) {
- return (DWORD)*pp;
- }
-
- static IClassUnknown * GetClsUnknown( DWORD dwCookie ) {
- return (IClassUnknown*)dwCookie;
- }
-
- IClassUnknown** begin() {
- return ( m_nSize < 2 ) ? &m_pUnk : m_ppUnk;
- }
-
- IClassUnknown** end() {
- return ( m_nSize < 2 ) ? (&m_pUnk)+m_nSize : &m_ppUnk[m_nSize];
- }
-
- IClassUnknown* GetAt( uint nIndex ) {
- if( nIndex < 0 || nIndex >= m_nSize )
- return NULL;
- return (m_nSize < 2) ? m_pUnk : m_ppUnk[nIndex];
- }
-
- uint GetSize() const { return m_nSize; }
-
- void clear() {
- if( m_nSize > 1 )
- free( m_ppUnk );
- m_nSize = 0;
- }
-
- protected:
- union {
- IClassUnknown** m_ppUnk;
- IClassUnknown* m_pUnk;
- };
- uint m_nSize;
- };
-
- //////////////////////////////////////////////////////////////////////////
- // IClassStream
- template<class T>
- class CClassStreamImpl : public T
- {
- protected:
- dword m_dwAllocated;
- dword m_dwDataSize;
- lpbyte m_pBuffer;
- dword m_dwPos;
-
- public:
- CClassStreamImpl() {
- m_dwAllocated = 0; m_dwDataSize = 0; m_pBuffer = 0; m_dwPos = 0;
- }
-
- virtual ~CClassStreamImpl() {
- if( m_pBuffer )
- free( m_pBuffer );
- }
-
- virtual dword get_Size() {
- return m_dwDataSize;
- }
-
- virtual dword Read( void *pBuf, dword Size ) {
- dword dwToRead = 0;
- if( pBuf && Size && m_pBuffer ) {
- dwToRead = Size;
- if( m_dwPos + Size > m_dwDataSize )
- dwToRead = m_dwPos + Size - m_dwDataSize;
- memcpy( pBuf, &m_pBuffer[m_dwPos], dwToRead );
- m_dwPos += dwToRead;
- }
- return dwToRead;
- }
-
- virtual dword Write( void *pBuf, dword Size ) {
- dword dwWritten = 0;
- if( m_dwAllocated - m_dwPos < Size ) {
- dword dwNewAllocSize = ( Size * 2 ) + m_dwAllocated;
- m_dwAllocated = dwNewAllocSize;
- m_pBuffer = (lpbyte)realloc( m_pBuffer, m_dwAllocated );
- }
- if( m_pBuffer && pBuf && Size ) {
- memcpy( &m_pBuffer[m_dwPos], pBuf, Size );
- m_dwPos += Size;
- dwWritten = Size;
- }
- return dwWritten;
- }
-
- virtual dword Seek( long Offset ) {
- if( Offset ) {
- dword dwMove = ABS( Offset );
- if( Offset < 0 ) {
- m_dwPos = ( m_dwPos < dwMove ) ? 0 : m_dwPos - dwMove;
- } else {
- m_dwPos = ( m_dwSize < dwMove ) ? m_dwSize : m_dwPos + dwMove;
- }
- }
- return m_dwPos;
- }
- };
-
- //////////////////////////////////////////////////////////////////////////
- // Variant
-
- enum VariantType
- {
- VAR_EMPTY = 0,
- VAR_CHAR,
- VAR_BYTE,
- VAR_SHORT,
- VAR_WORD,
- VAR_INTEGER,
- VAR_UINT,
- VAR_LONG,
- VAR_DWORD,
- VAR_FLOAT,
- VAR_DOUBLE,
- VAR_TIME,
- VAR_BSTRING,
- VAR_BIN,
- VAR_CLSUNKNOWN
- };
-
- typedef struct _Variant
- {
- VariantType vt;
- union
- {
- char cVal;
- byte bVal;
- short sVal;
- word wVal;
- int iVal;
- uint uiVal;
- long lVal;
- dword dwVal;
- float fVal;
- double dVal;
- vtime tVal;
- bstr strVal;
- lpbyte binVal;
- IClassUnknown *punkVal;
- };
- dword dwSize;
- } Variant;
-
- //////////////////////////////////////////////////////////////////////////
- // variant api
- inline void variant_init( Variant *pv ) {
- pv->vt = VAR_EMPTY;
- pv->dwVal = 0;
- pv->dwSize = 0;
- }
-
- inline void variant_clear( Variant *pv ) {
- switch( pv->vt ) {
- case VAR_EMPTY: break;
- case VAR_CHAR:
- case VAR_BYTE:
- case VAR_SHORT:
- case VAR_WORD:
- case VAR_INTEGER:
- case VAR_UINT:
- case VAR_LONG:
- case VAR_DWORD:
- pv->dwVal = 0;
- break;
- case VAR_FLOAT:
- pv->fVal = 0.0f;
- break;
- case VAR_DOUBLE:
- pv->dVal = 0.0;
- break;
- case VAR_TIME:
- pv->tVal = 0.0;
- break;
- case VAR_BSTRING:
- delete[] pv->strVal;
- break;
- case VAR_BIN:
- delete[] pv->binVal;
- break;
- case VAR_CLSUNKNOWN:
- pv->punkVal->Release();
- pv->punkVal = 0;
- break;
- }
- pv->vt = VAR_EMPTY;
- pv->dwSize = 0;
- }
-
- inline bool variant_copy( Variant *pDst, Variant *pSrc ) {
- if( pDst->vt != VAR_EMPTY )
- return false;
- pDst->dwSize = pSrc->dwSize;
- switch( pSrc->vt ) {
- case VAR_EMPTY: break;
- case VAR_CHAR: pDst->cVal = pSrc->cVal; break;
- case VAR_BYTE: pDst->bVal = pSrc->bVal; break;
- case VAR_SHORT: pDst->sVal = pSrc->sVal; break;
- case VAR_WORD: pDst->wVal = pSrc->wVal; break;
- case VAR_INTEGER: pDst->iVal = pSrc->iVal; break;
- case VAR_UINT: pDst->uiVal = pSrc->uiVal; break;
- case VAR_LONG: pDst->lVal = pSrc->lVal; break;
- case VAR_DWORD: pDst->dwVal = pSrc->dwVal; break;
- case VAR_FLOAT: pDst->fVal = pSrc->fVal; break;
- case VAR_DOUBLE: pDst->dVal = pSrc->dVal; break;
- case VAR_TIME: pDst->tVal = pSrc->tVal; break;
- case VAR_BSTRING:
- {
- if( !pSrc->dwSize )
- return false;
- pDst->strVal = new char[pSrc->dwSize+1];
- if( !pDst->strVal )
- return false;
- char *d = pDst->strVal;
- char *s = pSrc->strVal;
- while( *d++ = *s++ ) ;
- *d = 0;
- pDst->dwSize = pSrc->dwSize;
- }
- break;
- case VAR_BIN:
- {
- if( !pSrc->dwSize )
- return false;
- pDst->binVal = new byte[pSrc->dwSize];
- if( !pDst->binVal )
- return false;
- for( dword i = 0; i < pSrc->dwSize; i++ )
- pDst->binVal[i] = pSrc->binVal[i];
- pDst->dwSize = pSrc->dwSize;
- }
- break;
- case VAR_CLSUNKNOWN:
- if( !pSrc->punkVal )
- return false;
- pDst->punkVal = pSrc->punkVal;
- pDst->punkVal->AddRef();
- break;
- }
- pDst->vt = pSrc->vt;
- return true;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // CVariant
- class CVariant : public Variant
- {
- public:
- CVariant() { variant_init( this ); }
- ~CVariant() { variant_clear( this ); }
-
- CVariant( char c ) {
- vt = VAR_CHAR;
- cVal = c;
- dwSize = sizeof(char);
- }
-
- CVariant( byte b ) {
- vt = VAR_BYTE;
- bVal = b;
- dwSize = sizeof(byte);
- }
-
- CVariant( short s ) {
- vt = VAR_SHORT;
- sVal = s;
- dwSize = sizeof(short);
- }
-
- CVariant( word w ) {
- vt = VAR_WORD;
- wVal = w;
- dwSize = sizeof(word);
- }
-
- CVariant( int i ) {
- vt = VAR_INTEGER;
- iVal = i;
- dwSize = sizeof(int);
- }
-
- CVariant( uint u ) {
- vt = VAR_UINT;
- uiVal = u;
- dwSize = sizeof(uint);
- }
-
- CVariant( long l ) {
- vt = VAR_LONG;
- lVal = l;
- dwSize = sizeof(long);
- }
-
- CVariant( dword dw ) {
- vt = VAR_DWORD;
- dwVal = dw;
- dwSize = sizeof(dword);
- }
-
- CVariant( float f ) {
- vt = VAR_FLOAT;
- fVal = f;
- dwSize = sizeof(float);
- }
-
- CVariant( double d ) {
- vt = VAR_DOUBLE;
- dVal = d;
- dwSize = sizeof(double);
- }
-
- CVariant( lpcstr str ) {
- assert( str );
- vt = VAR_BSTRING;
- dwSize = strlen( str );
- strVal = new char[ dwSize + 1 ];
- char *d = strVal;
- const char *s = str;
- while( *d++ = *s++ ) ;
- *d = 0;
- }
-
- CVariant( lpbyte pbin, dword dwSize ) {
- assert( pbin );
- assert( dwSize != 0 );
- vt = VAR_BIN;
- dwSize = dwSize;
- binVal = new byte[ dwSize ];
- for( dword i = 0; i < dwSize; i++ )
- binVal[i] = pbin[i];
- }
-
- CVariant( IClassUnknown *punk ) {
- assert( punk );
- vt = VAR_CLSUNKNOWN;
- punkVal = punk;
- punkVal->AddRef();
- }
-
- CVariant( const Variant& v ) {
- variant_init( this );
- Variant *pv = const_cast<Variant*>( &v );
- variant_copy( this, pv );
- }
-
- CVariant& operator= ( const CVariant& v ) {
- variant_clear( this );
- CVariant *pv = const_cast<CVariant*>( &v );
- variant_copy( this, pv );
- return (*this);
- }
-
- void clear() {
- variant_clear( this );
- }
-
- };
-
- //////////////////////////////////////////////////////////////////////////
-
- #endif // __class_h__