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.

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