Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

235 lines
8.9 KiB

  1. /***
  2. *variant.h
  3. *
  4. * Copyright (C) 1992-1993, Microsoft Corporation. All Rights Reserved.
  5. *
  6. *Purpose:
  7. * This file declares VARIANT, and related data types.
  8. *
  9. *Implementation Notes:
  10. * This file requires ole2.h
  11. *
  12. *****************************************************************************/
  13. #ifndef _VARIANT_H_
  14. #define _VARIANT_H_
  15. #ifndef HUGEP
  16. # ifdef _MAC
  17. # define HUGEP FAR
  18. # elif WIN32
  19. # define HUGEP
  20. # else
  21. # define HUGEP _huge
  22. # endif
  23. #endif
  24. /* Forward Declarations */
  25. #ifdef __cplusplus
  26. interface IDispatch;
  27. #else
  28. typedef interface IDispatch IDispatch;
  29. #endif
  30. typedef char FAR* BSTR;
  31. typedef BSTR FAR* LPBSTR;
  32. typedef struct FARSTRUCT tagSAFEARRAYBOUND {
  33. ULONG cElements;
  34. LONG lLbound;
  35. } SAFEARRAYBOUND, FAR* LPSAFEARRAYBOUND;
  36. typedef struct FARSTRUCT tagSAFEARRAY {
  37. USHORT cDims;
  38. USHORT fFeatures;
  39. USHORT cbElements;
  40. USHORT cLocks;
  41. ULONG handle;
  42. void HUGEP* pvData;
  43. SAFEARRAYBOUND rgsabound[1];
  44. } SAFEARRAY, FAR* LPSAFEARRAY;
  45. #define FADF_AUTO 0x0001 /* array is allocated on the stack */
  46. #define FADF_STATIC 0x0002 /* array is staticly allocated */
  47. #define FADF_EMBEDDED 0x0004 /* array is embedded in a structure */
  48. #define FADF_FIXEDSIZE 0x0010 /* array may not be resized or reallocated */
  49. #define FADF_BSTR 0x0100 /* an array of BSTRs */
  50. #define FADF_UNKNOWN 0x0200 /* an array of IUnknown* */
  51. #define FADF_DISPATCH 0x0400 /* an array of IDispatch* */
  52. #define FADF_VARIANT 0x0800 /* an array of VARIANTs */
  53. #define FADF_RESERVED 0xF0E8 /* bits reserved for future use */
  54. /* 0 == FALSE, -1 == TRUE */
  55. typedef short VARIANT_BOOL;
  56. typedef double DATE;
  57. /* This is a helper struct for use in handling currency. */
  58. typedef struct FARSTRUCT tagCY {
  59. #ifdef _MAC
  60. long Hi;
  61. unsigned long Lo;
  62. #else
  63. unsigned long Lo;
  64. long Hi;
  65. #endif
  66. } CY;
  67. /*
  68. * VARENUM usage key,
  69. *
  70. * [V] - may appear in a VARIANT
  71. * [T] - may appear in a TYPEDESC
  72. * [P] - may appear in an OLE property set
  73. *
  74. */
  75. enum VARENUM
  76. {
  77. VT_EMPTY = 0, /* [V] [P] nothing */
  78. VT_NULL = 1, /* [V] SQL style Null */
  79. VT_I2 = 2, /* [V][T][P] 2 byte signed int */
  80. VT_I4 = 3, /* [V][T][P] 4 byte signed int */
  81. VT_R4 = 4, /* [V][T][P] 4 byte real */
  82. VT_R8 = 5, /* [V][T][P] 8 byte real */
  83. VT_CY = 6, /* [V][T][P] currency */
  84. VT_DATE = 7, /* [V][T][P] date */
  85. VT_BSTR = 8, /* [V][T][P] binary string */
  86. VT_DISPATCH = 9, /* [V][T] IDispatch FAR* */
  87. VT_ERROR = 10, /* [V][T] SCODE */
  88. VT_BOOL = 11, /* [V][T][P] True=-1, False=0 */
  89. VT_VARIANT = 12, /* [V][T][P] VARIANT FAR* */
  90. VT_UNKNOWN = 13, /* [V][T] IUnknown FAR* */
  91. VT_WBSTR = 14, /* [V][T] wide binary string */
  92. VT_I1 = 16, /* [T] signed char */
  93. VT_UI1 = 17, /* [T] unsigned char */
  94. VT_UI2 = 18, /* [T] unsigned short */
  95. VT_UI4 = 19, /* [T] unsigned short */
  96. VT_I8 = 20, /* [T][P] signed 64-bit int */
  97. VT_UI8 = 21, /* [T] unsigned 64-bit int */
  98. VT_INT = 22, /* [T] signed machine int */
  99. VT_UINT = 23, /* [T] unsigned machine int */
  100. VT_VOID = 24, /* [T] C style void */
  101. VT_HRESULT = 25, /* [T] */
  102. VT_PTR = 26, /* [T] pointer type */
  103. VT_SAFEARRAY = 27, /* [T] (use VT_ARRAY in VARIANT) */
  104. VT_CARRAY = 28, /* [T] C style array */
  105. VT_USERDEFINED = 29, /* [T] user defined type */
  106. VT_LPSTR = 30, /* [T][P] null terminated string */
  107. VT_LPWSTR = 31, /* [T][P] wide null terminated string */
  108. VT_FILETIME = 64, /* [P] FILETIME */
  109. VT_BLOB = 65, /* [P] Length prefixed bytes */
  110. VT_STREAM = 66, /* [P] Name of the stream follows */
  111. VT_STORAGE = 67, /* [P] Name of the storage follows */
  112. VT_STREAMED_OBJECT = 68, /* [P] Stream contains an object */
  113. VT_STORED_OBJECT = 69, /* [P] Storage contains an object */
  114. VT_BLOB_OBJECT = 70, /* [P] Blob contains an object */
  115. VT_CF = 71, /* [P] Clipboard format */
  116. VT_CLSID = 72 /* [P] A Class ID */
  117. };
  118. #define VT_VECTOR 0x1000 /* [P] simple counted array */
  119. #define VT_ARRAY 0x2000 /* [V] SAFEARRAY* */
  120. #define VT_BYREF 0x4000 /* [V] */
  121. #define VT_RESERVED 0x8000
  122. typedef unsigned short VARTYPE;
  123. typedef struct FARSTRUCT tagVARIANT VARIANT;
  124. typedef struct FARSTRUCT tagVARIANT FAR* LPVARIANT;
  125. typedef struct FARSTRUCT tagVARIANT VARIANTARG;
  126. typedef struct FARSTRUCT tagVARIANT FAR* LPVARIANTARG;
  127. struct FARSTRUCT tagVARIANT{
  128. VARTYPE vt;
  129. WORD wReserved1;
  130. WORD wReserved2;
  131. WORD wReserved3;
  132. union {
  133. short iVal; /* VT_I2 */
  134. long lVal; /* VT_I4 */
  135. float fltVal; /* VT_R4 */
  136. double dblVal; /* VT_R8 */
  137. VARIANT_BOOL bool; /* VT_BOOL */
  138. SCODE scode; /* VT_ERROR */
  139. CY cyVal; /* VT_CY */
  140. DATE date; /* VT_DATE */
  141. BSTR bstrVal; /* VT_BSTR */
  142. IUnknown FAR* punkVal; /* VT_UNKNOWN */
  143. IDispatch FAR* pdispVal; /* VT_DISPATCH */
  144. SAFEARRAY FAR* parray; /* VT_ARRAY|* */
  145. short FAR* piVal; /* VT_BYREF|VT_I2 */
  146. long FAR* plVal; /* VT_BYREF|VT_I4 */
  147. float FAR* pfltVal; /* VT_BYREF|VT_R4 */
  148. double FAR* pdblVal; /* VT_BYREF|VT_R8 */
  149. VARIANT_BOOL FAR* pbool; /* VT_BYREF|VT_BOOL */
  150. SCODE FAR* pscode; /* VT_BYREF|VT_ERROR */
  151. CY FAR* pcyVal; /* VT_BYREF|VT_CY */
  152. DATE FAR* pdate; /* VT_BYREF|VT_DATE */
  153. BSTR FAR* pbstrVal; /* VT_BYREF|VT_BSTR */
  154. IUnknown FAR* FAR* ppunkVal; /* VT_BYREF|VT_UNKNOWN */
  155. IDispatch FAR* FAR* ppdispVal; /* VT_BYREF|VT_DISPATCH */
  156. SAFEARRAY FAR* FAR* pparray; /* VT_BYREF|VT_ARRAY|* */
  157. VARIANT FAR* pvarVal; /* VT_BYREF|VT_VARIANT */
  158. void FAR* byref; /* Generic ByRef */
  159. }
  160. #ifdef NONAMELESSUNION
  161. u
  162. #endif
  163. ;
  164. };
  165. #ifdef NONAMELESSUNION
  166. # define V_UNION(X, Y) ((X)->u.Y)
  167. #else
  168. # define V_UNION(X, Y) ((X)->Y)
  169. #endif
  170. /* Variant access macros */
  171. #define V_VT(X) ((X)->vt)
  172. #define V_ISBYREF(X) (V_VT(X)&VT_BYREF)
  173. #define V_ISARRAY(X) (V_VT(X)&VT_ARRAY)
  174. #define V_ISVECTOR(X) (V_VT(X)&VT_VECTOR)
  175. #define V_NONE(X) V_I2(X)
  176. #define V_I2(X) V_UNION(X, iVal)
  177. #define V_I2REF(X) V_UNION(X, piVal)
  178. #define V_I4(X) V_UNION(X, lVal)
  179. #define V_I4REF(X) V_UNION(X, plVal)
  180. #define V_R4(X) V_UNION(X, fltVal)
  181. #define V_R4REF(X) V_UNION(X, pfltVal)
  182. #define V_R8(X) V_UNION(X, dblVal)
  183. #define V_R8REF(X) V_UNION(X, pdblVal)
  184. #define V_BOOL(X) V_UNION(X, bool)
  185. #define V_BOOLREF(X) V_UNION(X, pbool)
  186. #define V_ERROR(X) V_UNION(X, scode)
  187. #define V_ERRORREF(X) V_UNION(X, pscode)
  188. #define V_CY(X) V_UNION(X, cyVal)
  189. #define V_CYREF(X) V_UNION(X, pcyVal)
  190. #define V_DATE(X) V_UNION(X, date)
  191. #define V_DATEREF(X) V_UNION(X, pdate)
  192. #define V_BSTR(X) V_UNION(X, bstrVal)
  193. #define V_BSTRREF(X) V_UNION(X, pbstrVal)
  194. #define V_UNKNOWN(X) V_UNION(X, punkVal)
  195. #define V_UNKNOWNREF(X) V_UNION(X, ppunkVal)
  196. #define V_DISPATCH(X) V_UNION(X, pdispVal)
  197. #define V_DISPATCHREF(X) V_UNION(X, ppdispVal)
  198. #define V_VARIANTREF(X) V_UNION(X, pvarVal)
  199. #define V_ARRAY(X) V_UNION(X, parray)
  200. #define V_ARRAYREF(X) V_UNION(X, pparray)
  201. #define V_BYREF(X) V_UNION(X, byref)
  202. #endif /* _VARIANT_H_ */