home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1996 November
/
VPR9611B.ISO
/
vabasic
/
ntclnt.exe
/
DISK8
/
data.8
/
datab
/
INCLUDE
/
VVARIANT.H
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-29
|
15KB
|
453 lines
/*------------------------------------------------------------------------
* $Source: /rcs/crcs/general/vvariant.h,v $
* Checked in by: $Author: bing $
* $Date: 1996/04/10 00:41:40 $ $Revision: 1.16 $
*
* Copyright 1987, Techtrol Ltd.
* Copyright 1990, Visual Edge Software Ltd.
* -----------------------------------------
* ALL RIGHTS RESERVED. This notice is intended as a precaution against
* inadvertent publication, and shall not be deemed to constitute an
* acknowledgment that publication has occurred nor to imply any waiver
* of confidentiality. The year included in the notice is the year
* of the creation of the work.
*------------------------------------------------------------------------*/
/*------------------------------------------------------------------------
*
* Module Name: vvariant.h
* Module Description: Cross platform APIs for OLE/COM data types
*
* Date: May 1994
*
*------------------------------------------------------------------------*/
#ifndef VARIANT_H
#define VARIANT_H
#include <vnls.h>
#include <strutil.h>
#include <vtoolkit.h>
#ifdef USE_OLE2
/*---------------------------------------------------------------------*/
/* String API */
/*---------------------------------------------------------------------*/
# define VeSysAllocString SysAllocString
# define VeSysReAllocString SysReAllocString
# define VeSysAllocStringLen SysAllocStringLen
# define VeSysReAllocStringLen SysReAllocStringLen
# define VeSysFreeString SysFreeString
# define VeSysStringLen SysStringLen
/*---------------------------------------------------------------------*/
/* SafeArray API */
/*---------------------------------------------------------------------*/
#define VeSafeArrayAllocDescriptor SafeArrayAllocDescriptor
#define VeSafeArrayDestroyDescriptor SafeArrayDestroyDescriptor
#define VeSafeArrayCreate SafeArrayCreate
#define VeSafeArrayDestroy SafeArrayDestroy
#define VeSafeArrayGetDim SafeArrayGetDim
#define VeSafeArrayGetElemsize SafeArrayGetElemsize
#define VeSafeArrayGetUBound SafeArrayGetUBound
#define VeSafeArrayGetLBound SafeArrayGetLBound
#define VeSafeArrayAllocData SafeArrayAllocData
#define VeSafeArrayDestroyData SafeArrayDestroyData
#define VeSafeArrayLock SafeArrayLock
#define VeSafeArrayUnlock SafeArrayUnlock
#define VeSafeArrayAccessData SafeArrayAccessData
#define VeSafeArrayUnaccessData SafeArrayUnaccessData
#define VeSafeArrayGetElement SafeArrayGetElement
#define VeSafeArrayPutElement SafeArrayPutElement
#define VeSafeArrayCopy SafeArrayCopy
#define VeSafeArrayRedim SafeArrayRedim
/*---------------------------------------------------------------------*/
/* Variant API */
/*---------------------------------------------------------------------*/
#define VeVariantInit VariantInit
#define VeVariantClear VariantClear
#define VeVariantCopy VariantCopy
#define VeVariantCopyInd VariantCopyInd
/*---------------------------------------------------------------------*/
/* New Variant type */
/*---------------------------------------------------------------------*/
#define VT_VEOBJ 15
#define V_VEOBJ(X) V_UNION(X, punkVal)
#define V_VEOBJREF(X) V_UNION(X, ppunkVal)
#else
#include <visedge.h>
# ifndef FAR
# define FAR
# endif
# ifndef PASCAL
# define PASCAL VPASCAL
# endif
# ifndef HUGEP
# define HUGEP
# endif
# ifndef UINT
# define UINT unsigned int
# endif
# ifndef WORD
# define WORD unsigned short
# endif
# ifndef DWORD
# define DWORD unsigned long
# endif
# ifndef ULONG
# define ULONG unsigned long
# endif
# ifndef LONG
# define LONG long
# endif
# ifndef USHORT
# define USHORT unsigned short
# endif
# ifndef TRUE
# define TRUE 1
# endif
# ifndef FALSE
# define FALSE 0
# endif
#ifdef __cplusplus
# define EXTERN_C extern "C"
#else
# define EXTERN_C extern
#endif
#define STDAPICALLTYPE FAR
#define STDAPI_H(type) EXTERN_C VFUNCDECL(type) STDAPICALLTYPE
#define STDAPI_C(type) EXTERN_C VFUNCDEF(type) STDAPICALLTYPE
#define STDAPI_DECL STDAPI_H(HRESULT)
#define STDAPI_DEF STDAPI_C(HRESULT)
#include <vscode.h> /* Use our version of scode.h, not the OLE2 one.*/
typedef VTOleChar * BSTR;
typedef double DATE;
typedef unsigned short VARTYPE;
typedef struct { int dummy; } IDispatch;
#ifndef BIXLIB_HACK
/*
* Don't define IUnknown if BIXLIB_HACK is defined otherwise
* we get redefinition errors. This should be resolved in bixlib.cc.
*/
typedef struct { int dummy; } IUnknown;
#endif
/* 0 == FALSE, -1 == TRUE */
typedef short VARIANT_BOOL;
/* This is a helper struct for use in handling currency. */
typedef struct tagCY
{
unsigned long Lo;
long Hi;
} CY;
/*
* VARENUM usage key,
*
* [V] - may appear in a VARIANT
* [T] - may appear in a TYPEDESC
* [P] - may appear in an OLE property set
*/
enum VARENUM
{
VT_EMPTY = 0, /* [V] [P] nothing */
VT_NULL = 1, /* [V] SQL style Null */
VT_I2 = 2, /* [V][T][P] 2 byte signed int */
VT_I4 = 3, /* [V][T][P] 4 byte signed int */
VT_R4 = 4, /* [V][T][P] 4 byte real */
VT_R8 = 5, /* [V][T][P] 8 byte real */
VT_CY = 6, /* [V][T][P] currency */
VT_DATE = 7, /* [V][T][P] date */
VT_BSTR = 8, /* [V][T][P] binary string */
VT_DISPATCH = 9, /* [V][T] IDispatch * */
VT_ERROR = 10, /* [V][T] SCODE */
VT_BOOL = 11, /* [V][T][P] True=-1, False=0 */
VT_VARIANT = 12, /* [V][T][P] VARIANT * */
VT_UNKNOWN = 13, /* [V][T] IUnknown * */
VT_WBSTR = 14, /* [V][T] wide binary string */
VT_VEOBJ = 15, /* [V][T] VE Object */
/*
* - The following a currently not supported but mentioned in OLE 2.0
* header file 'variant.h'.
*/
VT_I1 = 16, /* [T] signed char */
VT_UI1 = 17, /* [V][T] unsigned char */
VT_UI2 = 18, /* [T] unsigned short */
VT_UI4 = 19, /* [T] unsigned short */
VT_I8 = 20, /* [T][P] signed 64-bit int */
VT_UI8 = 21, /* [T] unsigned 64-bit int */
VT_INT = 22, /* [T] signed machine int */
VT_UINT = 23, /* [T] unsigned machine int */
VT_VOID = 24, /* [T] C style void */
VT_HRESULT = 25, /* [T] */
VT_PTR = 26, /* [T] pointer type */
VT_SAFEARRAY = 27, /* [T] (use VT_ARRAY in VARIANT) */
VT_CARRAY = 28, /* [T] C style array */
VT_USERDEFINED = 29, /* [T] user defined type */
VT_LPSTR = 30, /* [T][P] null terminated string */
VT_LPWSTR = 31, /* [T][P] wide null terminated string */
VT_FILETIME = 64, /* [P] FILETIME */
VT_BLOB = 65, /* [P] Length prefixed bytes */
VT_STREAM = 66, /* [P] Name of the stream follows */
VT_STORAGE = 67, /* [P] Name of the storage follows */
VT_STREAMED_OBJECT = 68, /* [P] Stream contains an object */
VT_STORED_OBJECT = 69, /* [P] Storage contains an object */
VT_BLOB_OBJECT = 70, /* [P] Blob contains an object */
VT_CF = 71, /* [P] Clipboard format */
VT_CLSID = 72 /* [P] A Class ID */
};
#define VT_VECTOR 0x1000 /* [P] simple counted array */
#define VT_ARRAY 0x2000 /* [V] SAFEARRAY* */
#define VT_BYREF 0x4000 /* [V] */
#define VT_RESERVED 0x8000
typedef struct
{
unsigned long cElements;
long lLbound;
} SAFEARRAYBOUND;
typedef struct tagSAFEARRAY *LPSAFEARRAY;
typedef struct tagSAFEARRAY
{
#ifdef VE_INTERNAL
void* pValidate; /* Pointer to itself for validation */
#endif
unsigned short cDims; /* Number of dimensions. */
unsigned short fFeatures; /* SafeArray Flags. */
unsigned short cbElements; /* Size of one element. */
unsigned short cLocks; /* Number of locks on array. */
unsigned long handle; /* Handle on array. */
void* pvData; /* Pointer to data. */
SAFEARRAYBOUND rgsabound[1]; /* Array of dimensions. */
} SAFEARRAY;
#define FADF_AUTO 0x0001 /* array is allocated on the stack */
#define FADF_STATIC 0x0002 /* array is staticly allocated */
#define FADF_EMBEDDED 0x0004 /* array is embedded in a structure */
#define FADF_FIXEDSIZE 0x0010 /* array may not be resized or reallocated */
#define FADF_BSTR 0x0100 /* an array of BSTRs */
#define FADF_UNKNOWN 0x0200 /* an array of IUnknown* */
#define FADF_DISPATCH 0x0400 /* an array of IDispatch* */
#define FADF_VARIANT 0x0800 /* an array of VARIANTs */
#define FADF_RESERVED 0xF0E8 /* bits reserved for future use */
typedef struct tagVARIANT *LPVARIANT;
typedef struct tagVARIANT VARIANTARG;
typedef struct tagVARIANT *LPVARIANTARG;
typedef struct tagVARIANT
{
VARTYPE vt;
WORD wReserved1;
WORD wReserved2;
WORD wReserved3;
union {
unsigned char bVal; /* VT_UI1 */
short iVal; /* VT_I2 */
long lVal; /* VT_I4 */
struct { float f;} fltVal; /* VT_R4 */
struct { double d;} dblVal; /* VT_R8 */
VARIANT_BOOL MS_bool; /* VT_BOOL */
SCODE scode; /* VT_ERROR */
CY cyVal; /* VT_CY */
struct { DATE d;} date; /* VT_DATE */
BSTR bstrVal; /* VT_BSTR */
IUnknown *punkVal; /* VT_UNKNOWN */
IDispatch *pdispVal; /* VT_DISPATCH */
LPSAFEARRAY parray; /* VT_ARRAY|* */
unsigned char *pbVal; /* VT_BYREF|VT_UI1 */
short *piVal; /* VT_BYREF|VT_I2 */
long *plVal; /* VT_BYREF|VT_I4 */
float *pfltVal; /* VT_BYREF|VT_R4 */
double *pdblVal; /* VT_BYREF|VT_R8 */
VARIANT_BOOL *pbool; /* VT_BYREF|VT_BOOL */
SCODE *pscode; /* VT_BYREF|VT_ERROR */
CY *pcyVal; /* VT_BYREF|VT_CY */
DATE *pdate; /* VT_BYREF|VT_DATE */
BSTR *pbstrVal; /* VT_BYREF|VT_BSTR */
IUnknown **ppunkVal;/* VT_BYREF|VT_UNKNOWN */
IDispatch **ppdispVal;/* VT_BYREF|VT_DISPATCH*/
LPSAFEARRAY *pparray; /* VT_BYREF|VT_ARRAY|* */
LPVARIANT pvarVal; /* VT_BYREF|VT_VARIANT */
void *byref; /* Generic ByRef */
} u;
} VARIANT;
#define V_UNION(X, Y) ((X)->u.Y)
/* Variant access macros */
#define V_VT(X) ((X)->vt)
#define V_ISBYREF(X) (V_VT(X)&VT_BYREF)
#define V_ISARRAY(X) (V_VT(X)&VT_ARRAY)
#define V_ISVECTOR(X) (V_VT(X)&VT_VECTOR)
#define V_NONE(X) V_I2(X)
#define V_UI1(X) V_UNION(X, bVal)
#define V_UI1REF(X) V_UNION(X, pbVal)
#define V_I2(X) V_UNION(X, iVal)
#define V_I2REF(X) V_UNION(X, piVal)
#define V_I4(X) V_UNION(X, lVal)
#define V_I4REF(X) V_UNION(X, plVal)
#define V_R4(X) V_UNION(X, fltVal.f)
#define V_R4REF(X) V_UNION(X, pfltVal)
#define V_R8(X) V_UNION(X, dblVal.d)
#define V_R8REF(X) V_UNION(X, pdblVal)
#define V_BOOL(X) V_UNION(X, MS_bool)
#define V_BOOLREF(X) V_UNION(X, pbool)
#define V_ERROR(X) V_UNION(X, scode)
#define V_ERRORREF(X) V_UNION(X, pscode)
#define V_CY(X) V_UNION(X, cyVal)
#define V_CYREF(X) V_UNION(X, pcyVal)
#define V_DATE(X) V_UNION(X, date.d)
#define V_DATEREF(X) V_UNION(X, pdate)
#define V_BSTR(X) V_UNION(X, bstrVal)
#define V_BSTRREF(X) V_UNION(X, pbstrVal)
#define V_UNKNOWN(X) V_UNION(X, punkVal)
#define V_UNKNOWNREF(X) V_UNION(X, ppunkVal)
#define V_DISPATCH(X) V_UNION(X, pdispVal)
#define V_DISPATCHREF(X) V_UNION(X, ppdispVal)
#define V_VEOBJ(X) V_UNION(X, punkVal)
#define V_VEOBJREF(X) V_UNION(X, ppunkVal)
#define V_VARIANTREF(X) V_UNION(X, pvarVal)
#define V_ARRAY(X) V_UNION(X, parray)
#define V_ARRAYREF(X) V_UNION(X, pparray)
#define V_BYREF(X) V_UNION(X, byref)
#ifdef __cplusplus
extern "C"
{
#endif
/*---------------------------------------------------------------------*/
/* String API */
/*---------------------------------------------------------------------*/
VFUNCDECL(BSTR) VeSysAllocString (VTOleChar *);
VFUNCDECL(bool_t)VeSysReAllocString (BSTR *, VTOleChar *);
VFUNCDECL(BSTR) VeSysAllocStringLen (VTOleChar *, UINT);
VFUNCDECL(bool_t)VeSysReAllocStringLen (BSTR *, VTOleChar *, UINT);
VFUNCDECL(void) VeSysFreeString (BSTR);
VFUNCDECL(UINT) VeSysStringLen (BSTR);
/*---------------------------------------------------------------------*/
/* SafeArray API */
/*---------------------------------------------------------------------*/
VFUNCDECL(HRESULT) VeSafeArrayAllocDescriptor(
UINT cDims,
LPSAFEARRAY *rtrn);
VFUNCDECL(HRESULT) VeSafeArrayDestroyDescriptor(LPSAFEARRAY psa);
VFUNCDECL(HRESULT) VeSafeArrayDestroy(LPSAFEARRAY psa);
VFUNCDECL(LPSAFEARRAY) VeSafeArrayCreate(
VARTYPE vt,
UINT cDims,
SAFEARRAYBOUND *rgsabound);
VFUNCDECL(HRESULT) VeSafeArrayDestroy(LPSAFEARRAY psa);
VFUNCDECL(UINT) VeSafeArrayGetDim(LPSAFEARRAY psa);
VFUNCDECL(UINT) VeSafeArrayGetElemsize(LPSAFEARRAY psa);
VFUNCDECL(HRESULT) VeSafeArrayGetUBound(
LPSAFEARRAY psa,
UINT nDim,
LONG *plUbound);
VFUNCDECL(HRESULT) VeSafeArrayGetLBound(
LPSAFEARRAY psa,
UINT nDim,
LONG *plLbound);
VFUNCDECL(HRESULT) VeSafeArrayAllocData(SAFEARRAY *pSafeArray);
VFUNCDECL(HRESULT) VeSafeArrayDestroyData(SAFEARRAY *psa);
VFUNCDECL(HRESULT) VeSafeArrayLock(LPSAFEARRAY psa);
VFUNCDECL(HRESULT) VeSafeArrayUnlock(LPSAFEARRAY psa);
VFUNCDECL(HRESULT) VeSafeArrayAccessData(
LPSAFEARRAY psa,
void * HUGEP*ppvData);
VFUNCDECL(HRESULT) VeSafeArrayUnaccessData(LPSAFEARRAY psa);
VFUNCDECL(HRESULT) VeSafeArrayGetElement(
LPSAFEARRAY psa,
LONG *rgIndices,
void *pv);
VFUNCDECL(HRESULT) VeSafeArrayPutElement(
LPSAFEARRAY psa,
LONG *rgIndices,
void *pv);
VFUNCDECL(HRESULT) VeSafeArrayCopy(
LPSAFEARRAY psa,
LPSAFEARRAY *ppsaOut);
VFUNCDECL(HRESULT) VeSafeArrayRedim(
SAFEARRAY *pSafeArray,
SAFEARRAYBOUND *psaboundNew);
/*---------------------------------------------------------------------*/
/* Variant API */
/*---------------------------------------------------------------------*/
VFUNCDECL(void) VeVariantInit(LPVARIANTARG pvarg);
VFUNCDECL(HRESULT) VeVariantClear(LPVARIANTARG pvarg);
VFUNCDECL(HRESULT) VeVariantCopy(
LPVARIANTARG pvargDest,
LPVARIANTARG pvargSrc);
VFUNCDECL(HRESULT) VeVariantCopyInd(
LPVARIANTARG pvarDest,
LPVARIANTARG pvargSrc);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* USE_OLE2 */
#endif /* VARIANT_H */