ReactOS  0.4.14-dev-337-gf981a68
variant.h File Reference
#include "windef.h"
#include "winerror.h"
#include "objbase.h"
#include "oleauto.h"
#include <math.h>
Include dependency graph for variant.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tagVARIANT_NUMBER_CHARS
 

Macros

#define V_TYPE(v)   (V_VT((v)) & VT_TYPEMASK)
 
#define VT_EXTRA_TYPE   (VT_VECTOR|VT_ARRAY|VT_BYREF|VT_RESERVED)
 
#define V_EXTRA_TYPE(v)   (V_VT((v)) & VT_EXTRA_TYPE)
 
#define VTBIT_BOOL   (1 << VT_BSTR)
 
#define VTBIT_BSTR   (1 << VT_BSTR)
 
#define VTBIT_DATE   (1 << VT_DATE)
 
#define VTBIT_DISPATCH   (1 << VT_DISPATCH)
 
#define VTBIT_EMPTY   (1 << VT_EMPTY)
 
#define VTBIT_ERROR   (1 << VT_ERROR)
 
#define VTBIT_INT   (1 << VT_INT)
 
#define VTBIT_NULL   (1 << VT_NULL)
 
#define VTBIT_UINT   (1 << VT_UINT)
 
#define VTBIT_UNKNOWN   (1 << VT_UNKNOWN)
 
#define VTBIT_VARIANT   (1 << VT_VARIANT)
 
#define VTBIT_15   (1 << 15) /* no variant type with this number */
 
#define I1_MAX   0x7f
 
#define I1_MIN   ((-I1_MAX)-1)
 
#define UI1_MAX   0xff
 
#define UI1_MIN   0
 
#define I2_MAX   0x7fff
 
#define I2_MIN   ((-I2_MAX)-1)
 
#define UI2_MAX   0xffff
 
#define UI2_MIN   0
 
#define I4_MAX   0x7fffffff
 
#define I4_MIN   ((-I4_MAX)-1)
 
#define UI4_MAX   0xffffffff
 
#define UI4_MIN   0
 
#define I8_MAX   (((LONGLONG)I4_MAX << 32) | UI4_MAX)
 
#define I8_MIN   ((-I8_MAX)-1)
 
#define UI8_MAX   (((ULONGLONG)UI4_MAX << 32) | UI4_MAX)
 
#define UI8_MIN   0
 
#define DATE_MAX   2958465
 
#define DATE_MIN   -657434
 
#define R4_MAX   3.402823567797336e38
 
#define R4_MIN   1.40129846432481707e-45
 
#define R8_MAX   1.79769313486231470e+308
 
#define R8_MIN   4.94065645841246544e-324
 
#define DECIMAL_POS   0
 
#define SIGNSCALE(sign, scale)   (((sign) << 8) | scale)
 
#define DEC_SIGN(d)   ((d)->u.s.sign)
 
#define DEC_SCALE(d)   ((d)->u.s.scale)
 
#define DEC_SIGNSCALE(d)   ((d)->u.signscale)
 
#define DEC_HI32(d)   ((d)->Hi32)
 
#define DEC_MID32(d)   ((d)->u1.s1.Mid32)
 
#define DEC_LO32(d)   ((d)->u1.s1.Lo32)
 
#define DEC_LO64(d)   ((d)->u1.Lo64)
 
#define DEC_MAX_SCALE   28 /* Maximum scale for a decimal */
 
#define VAR_BOOLONOFF   0x0400 /* Convert bool to "On"/"Off" */
 
#define VAR_BOOLYESNO   0x0800 /* Convert bool to "Yes"/"No" */
 
#define VAR_NEGATIVE   0x1000 /* Number is negative */
 

Typedefs

typedef struct tagVARIANT_NUMBER_CHARS VARIANT_NUMBER_CHARS
 

Functions

unsigned int get_type_size (ULONG *, VARTYPE) DECLSPEC_HIDDEN
 
HRESULT VARIANT_ClearInd (VARIANTARG *) DECLSPEC_HIDDEN
 
BOOL get_date_format (LCID, DWORD, const SYSTEMTIME *, const WCHAR *, WCHAR *, int) DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ DATE_MAX

#define DATE_MAX   2958465

Definition at line 69 of file variant.h.

◆ DATE_MIN

#define DATE_MIN   -657434

Definition at line 70 of file variant.h.

◆ DEC_HI32

#define DEC_HI32 (   d)    ((d)->Hi32)

Definition at line 94 of file variant.h.

◆ DEC_LO32

#define DEC_LO32 (   d)    ((d)->u1.s1.Lo32)

Definition at line 96 of file variant.h.

◆ DEC_LO64

#define DEC_LO64 (   d)    ((d)->u1.Lo64)

Definition at line 97 of file variant.h.

◆ DEC_MAX_SCALE

#define DEC_MAX_SCALE   28 /* Maximum scale for a decimal */

Definition at line 99 of file variant.h.

◆ DEC_MID32

#define DEC_MID32 (   d)    ((d)->u1.s1.Mid32)

Definition at line 95 of file variant.h.

◆ DEC_SCALE

#define DEC_SCALE (   d)    ((d)->u.s.scale)

Definition at line 92 of file variant.h.

◆ DEC_SIGN

#define DEC_SIGN (   d)    ((d)->u.s.sign)

Definition at line 91 of file variant.h.

◆ DEC_SIGNSCALE

#define DEC_SIGNSCALE (   d)    ((d)->u.signscale)

Definition at line 93 of file variant.h.

◆ DECIMAL_POS

#define DECIMAL_POS   0

Definition at line 77 of file variant.h.

◆ I1_MAX

#define I1_MAX   0x7f

Definition at line 53 of file variant.h.

◆ I1_MIN

#define I1_MIN   ((-I1_MAX)-1)

Definition at line 54 of file variant.h.

◆ I2_MAX

#define I2_MAX   0x7fff

Definition at line 57 of file variant.h.

◆ I2_MIN

#define I2_MIN   ((-I2_MAX)-1)

Definition at line 58 of file variant.h.

◆ I4_MAX

#define I4_MAX   0x7fffffff

Definition at line 61 of file variant.h.

◆ I4_MIN

#define I4_MIN   ((-I4_MAX)-1)

Definition at line 62 of file variant.h.

◆ I8_MAX

#define I8_MAX   (((LONGLONG)I4_MAX << 32) | UI4_MAX)

Definition at line 65 of file variant.h.

◆ I8_MIN

#define I8_MIN   ((-I8_MAX)-1)

Definition at line 66 of file variant.h.

◆ R4_MAX

#define R4_MAX   3.402823567797336e38

Definition at line 71 of file variant.h.

◆ R4_MIN

#define R4_MIN   1.40129846432481707e-45

Definition at line 72 of file variant.h.

◆ R8_MAX

#define R8_MAX   1.79769313486231470e+308

Definition at line 73 of file variant.h.

◆ R8_MIN

#define R8_MIN   4.94065645841246544e-324

Definition at line 74 of file variant.h.

◆ SIGNSCALE

#define SIGNSCALE (   sign,
  scale 
)    (((sign) << 8) | scale)

Definition at line 87 of file variant.h.

◆ UI1_MAX

#define UI1_MAX   0xff

Definition at line 55 of file variant.h.

◆ UI1_MIN

#define UI1_MIN   0

Definition at line 56 of file variant.h.

◆ UI2_MAX

#define UI2_MAX   0xffff

Definition at line 59 of file variant.h.

◆ UI2_MIN

#define UI2_MIN   0

Definition at line 60 of file variant.h.

◆ UI4_MAX

#define UI4_MAX   0xffffffff

Definition at line 63 of file variant.h.

◆ UI4_MIN

#define UI4_MIN   0

Definition at line 64 of file variant.h.

◆ UI8_MAX

#define UI8_MAX   (((ULONGLONG)UI4_MAX << 32) | UI4_MAX)

Definition at line 67 of file variant.h.

◆ UI8_MIN

#define UI8_MIN   0

Definition at line 68 of file variant.h.

◆ V_EXTRA_TYPE

#define V_EXTRA_TYPE (   v)    (V_VT((v)) & VT_EXTRA_TYPE)

Definition at line 36 of file variant.h.

◆ V_TYPE

#define V_TYPE (   v)    (V_VT((v)) & VT_TYPEMASK)

Definition at line 30 of file variant.h.

◆ VAR_BOOLONOFF

#define VAR_BOOLONOFF   0x0400 /* Convert bool to "On"/"Off" */

Definition at line 102 of file variant.h.

◆ VAR_BOOLYESNO

#define VAR_BOOLYESNO   0x0800 /* Convert bool to "Yes"/"No" */

Definition at line 103 of file variant.h.

◆ VAR_NEGATIVE

#define VAR_NEGATIVE   0x1000 /* Number is negative */

Definition at line 104 of file variant.h.

◆ VT_EXTRA_TYPE

#define VT_EXTRA_TYPE   (VT_VECTOR|VT_ARRAY|VT_BYREF|VT_RESERVED)

Definition at line 33 of file variant.h.

◆ VTBIT_15

#define VTBIT_15   (1 << 15) /* no variant type with this number */

Definition at line 50 of file variant.h.

◆ VTBIT_BOOL

#define VTBIT_BOOL   (1 << VT_BSTR)

Definition at line 39 of file variant.h.

◆ VTBIT_BSTR

#define VTBIT_BSTR   (1 << VT_BSTR)

Definition at line 40 of file variant.h.

◆ VTBIT_DATE

#define VTBIT_DATE   (1 << VT_DATE)

Definition at line 41 of file variant.h.

◆ VTBIT_DISPATCH

#define VTBIT_DISPATCH   (1 << VT_DISPATCH)

Definition at line 42 of file variant.h.

◆ VTBIT_EMPTY

#define VTBIT_EMPTY   (1 << VT_EMPTY)

Definition at line 43 of file variant.h.

◆ VTBIT_ERROR

#define VTBIT_ERROR   (1 << VT_ERROR)

Definition at line 44 of file variant.h.

◆ VTBIT_INT

#define VTBIT_INT   (1 << VT_INT)

Definition at line 45 of file variant.h.

◆ VTBIT_NULL

#define VTBIT_NULL   (1 << VT_NULL)

Definition at line 46 of file variant.h.

◆ VTBIT_UINT

#define VTBIT_UINT   (1 << VT_UINT)

Definition at line 47 of file variant.h.

◆ VTBIT_UNKNOWN

#define VTBIT_UNKNOWN   (1 << VT_UNKNOWN)

Definition at line 48 of file variant.h.

◆ VTBIT_VARIANT

#define VTBIT_VARIANT   (1 << VT_VARIANT)

Definition at line 49 of file variant.h.

Typedef Documentation

◆ VARIANT_NUMBER_CHARS

Function Documentation

◆ get_date_format()

BOOL get_date_format ( LCID  ,
DWORD  ,
const SYSTEMTIME ,
const WCHAR ,
WCHAR ,
int   
)

Definition at line 6667 of file vartype.c.

6669 {
6670  static const LCTYPE dayname[] = {
6673  };
6674  static const LCTYPE sdayname[] = {
6678  };
6679  static const LCTYPE monthname[] = {
6683  };
6684  static const LCTYPE smonthname[] = {
6689  };
6690 
6692  FIXME("ignoring flags %x\n", flags);
6694 
6695  while(*fmt && date_len) {
6696  int count = 1;
6697 
6698  switch(*fmt) {
6699  case 'd':
6700  case 'M':
6701  case 'y':
6702  case 'g':
6703  while(*fmt == *(fmt+count))
6704  count++;
6705  fmt += count-1;
6706  }
6707 
6708  switch(*fmt) {
6709  case 'd':
6710  if(count >= 4)
6711  count = GetLocaleInfoW(lcid, dayname[st->wDayOfWeek] | flags, date, date_len)-1;
6712  else if(count == 3)
6713  count = GetLocaleInfoW(lcid, sdayname[st->wDayOfWeek] | flags, date, date_len)-1;
6714  else
6715  count = output_int_len(st->wDay, count, date, date_len);
6716  break;
6717  case 'M':
6718  if(count >= 4)
6719  count = GetLocaleInfoW(lcid, monthname[st->wMonth-1] | flags, date, date_len)-1;
6720  else if(count == 3)
6721  count = GetLocaleInfoW(lcid, smonthname[st->wMonth-1] | flags, date, date_len)-1;
6722  else
6723  count = output_int_len(st->wMonth, count, date, date_len);
6724  break;
6725  case 'y':
6726  if(count >= 3)
6727  count = output_int_len(st->wYear, 0, date, date_len);
6728  else
6729  count = output_int_len(st->wYear%100, count, date, date_len);
6730  break;
6731  case 'g':
6732  if(count == 2) {
6733  FIXME("Should be using GetCalendarInfo(CAL_SERASTRING), defaulting to 'AD'\n");
6734 
6735  *date++ = 'A';
6736  date_len--;
6737  if(date_len)
6738  *date = 'D';
6739  else
6740  count = -1;
6741  break;
6742  }
6743  /* fall through */
6744  default:
6745  *date = *fmt;
6746  }
6747 
6748  if(count < 0)
6749  break;
6750  fmt++;
6751  date += count;
6752  date_len -= count;
6753  }
6754 
6755  if(!date_len)
6756  return FALSE;
6757  *date++ = 0;
6758  return TRUE;
6759 }
#define LOCALE_SABBREVMONTHNAME12
Definition: winnls.h:115
#define TRUE
Definition: types.h:120
#define LOCALE_SABBREVDAYNAME2
Definition: winnls.h:85
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
#define LOCALE_SMONTHNAME5
Definition: winnls.h:95
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:109
#define LOCALE_SMONTHNAME2
Definition: winnls.h:92
#define LOCALE_SABBREVDAYNAME4
Definition: winnls.h:87
#define LOCALE_SABBREVDAYNAME7
Definition: winnls.h:90
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define LOCALE_SDAYNAME2
Definition: winnls.h:78
const char * fmt
Definition: wsprintf.c:30
#define LOCALE_SMONTHNAME6
Definition: winnls.h:96
#define LOCALE_SABBREVMONTHNAME7
Definition: winnls.h:110
#define LOCALE_SABBREVMONTHNAME3
Definition: winnls.h:106
#define LOCALE_SMONTHNAME8
Definition: winnls.h:98
#define LOCALE_SABBREVMONTHNAME8
Definition: winnls.h:111
#define LOCALE_SDAYNAME5
Definition: winnls.h:81
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_SDAYNAME1
Definition: winnls.h:77
#define LOCALE_SABBREVDAYNAME3
Definition: winnls.h:86
#define LOCALE_SABBREVMONTHNAME5
Definition: winnls.h:108
DWORD LCTYPE
Definition: winnls.h:514
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define LOCALE_SABBREVMONTHNAME10
Definition: winnls.h:113
#define LOCALE_SABBREVDAYNAME6
Definition: winnls.h:89
#define FIXME(fmt,...)
Definition: debug.h:110
#define LOCALE_SABBREVMONTHNAME4
Definition: winnls.h:107
#define LOCALE_SMONTHNAME4
Definition: winnls.h:94
#define LOCALE_SDAYNAME4
Definition: winnls.h:80
#define LOCALE_SMONTHNAME11
Definition: winnls.h:101
#define VAR_DATEVALUEONLY
Definition: oleauto.h:327
#define LOCALE_SDAYNAME3
Definition: winnls.h:79
#define LOCALE_SMONTHNAME10
Definition: winnls.h:100
#define LOCALE_SABBREVMONTHNAME2
Definition: winnls.h:105
#define LOCALE_SDAYNAME7
Definition: winnls.h:83
GLbitfield flags
Definition: glext.h:7161
#define LOCALE_SMONTHNAME3
Definition: winnls.h:93
#define LOCALE_SDAYNAME6
Definition: winnls.h:82
#define LOCALE_SABBREVMONTHNAME9
Definition: winnls.h:112
#define LOCALE_SABBREVMONTHNAME11
Definition: winnls.h:114
#define LOCALE_SABBREVDAYNAME5
Definition: winnls.h:88
__u16 date
Definition: mkdosfs.c:366
#define LOCALE_SMONTHNAME9
Definition: winnls.h:99
#define LOCALE_SMONTHNAME12
Definition: winnls.h:102
#define LOCALE_SMONTHNAME7
Definition: winnls.h:97
static int output_int_len(int o, int min_len, WCHAR *date, int date_len)
Definition: vartype.c:6647
Definition: dsound.c:943

Referenced by VarBstrFromDate(), and VARIANT_FormatDate().

◆ get_type_size()

unsigned int get_type_size ( ULONG ,
VARTYPE   
)

Definition at line 209 of file usrmarshal.c.

210 {
211  if (vt & VT_ARRAY) return 4;
212 
213  switch (vt & ~VT_BYREF) {
214  case VT_EMPTY:
215  case VT_NULL:
216  return 0;
217  case VT_I1:
218  case VT_UI1:
219  return sizeof(CHAR);
220  case VT_I2:
221  case VT_UI2:
222  return sizeof(SHORT);
223  case VT_I4:
224  case VT_UI4:
225  case VT_HRESULT:
226  return sizeof(LONG);
227  case VT_INT:
228  case VT_UINT:
229  return sizeof(INT);
230  case VT_I8:
231  case VT_UI8:
232  return sizeof(LONGLONG);
233  case VT_R4:
234  return sizeof(FLOAT);
235  case VT_R8:
236  return sizeof(DOUBLE);
237  case VT_BOOL:
238  return sizeof(VARIANT_BOOL);
239  case VT_ERROR:
240  return sizeof(SCODE);
241  case VT_DATE:
242  return sizeof(DATE);
243  case VT_CY:
244  return sizeof(CY);
245  case VT_DECIMAL:
246  return sizeof(DECIMAL);
247  case VT_BSTR:
248  return sizeof(ULONG);
249  case VT_VARIANT:
250  return sizeof(VARIANT);
251  case VT_UNKNOWN:
252  case VT_DISPATCH:
253  case VT_RECORD:
254  return 0;
255  default:
256  FIXME("unhandled VT %d\n", vt);
257  return 0;
258  }
259 }
#define DOUBLE(x)
Definition: atom.c:30
struct tagVARIANT VARIANT
Definition: compat.h:2026
Definition: compat.h:1947
Definition: compat.h:1963
#define FLOAT
Definition: i386-dis.c:516
Definition: compat.h:1959
static GUID *static VARTYPE *static ULONG
Definition: usrmarshal.c:41
#define INT
Definition: polytest.cpp:20
double DATE
Definition: compat.h:1902
short VARIANT_BOOL
Definition: compat.h:1939
long LONG
Definition: pedump.c:60
short SHORT
Definition: pedump.c:59
#define FIXME(fmt,...)
Definition: debug.h:110
LONG SCODE
Definition: compat.h:1901
union tagCY CY
int64_t LONGLONG
Definition: typedefs.h:66
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:85
Definition: compat.h:1948
Definition: compat.h:1950
struct tagDEC DECIMAL
#define CHAR(Char)
Definition: compat.h:1949
Definition: compat.h:1946

Referenced by create_signature_columns_and_data(), destroy_array(), get_type_alignment(), IRecordInfoImpl_RecordCopy(), to_array(), to_safearray(), VARIANT_UserMarshal(), VARIANT_UserSize(), and VARIANT_UserUnmarshal().

◆ VARIANT_ClearInd()

HRESULT VARIANT_ClearInd ( VARIANTARG )

Definition at line 579 of file variant.c.

580 {
581  HRESULT hres;
582 
583  TRACE("(%s)\n", debugstr_variant(pVarg));
584 
585  hres = VARIANT_ValidateType(V_VT(pVarg));
586  if (FAILED(hres))
587  return hres;
588 
589  switch (V_VT(pVarg))
590  {
591  case VT_DISPATCH:
592  case VT_UNKNOWN:
593  if (V_UNKNOWN(pVarg))
594  IUnknown_Release(V_UNKNOWN(pVarg));
595  break;
596  case VT_UNKNOWN | VT_BYREF:
597  case VT_DISPATCH | VT_BYREF:
598  if(*V_UNKNOWNREF(pVarg))
599  IUnknown_Release(*V_UNKNOWNREF(pVarg));
600  break;
601  case VT_BSTR:
602  SysFreeString(V_BSTR(pVarg));
603  break;
604  case VT_BSTR | VT_BYREF:
605  SysFreeString(*V_BSTRREF(pVarg));
606  break;
607  case VT_VARIANT | VT_BYREF:
608  VariantClear(V_VARIANTREF(pVarg));
609  break;
610  case VT_RECORD:
611  case VT_RECORD | VT_BYREF:
612  {
613  struct __tagBRECORD* pBr = &V_UNION(pVarg,brecVal);
614  if (pBr->pRecInfo)
615  {
616  IRecordInfo_RecordClear(pBr->pRecInfo, pBr->pvRecord);
617  IRecordInfo_Release(pBr->pRecInfo);
618  }
619  break;
620  }
621  default:
622  if (V_ISARRAY(pVarg) || (V_VT(pVarg) & ~VT_BYREF) == VT_SAFEARRAY)
623  {
624  if (V_ISBYREF(pVarg))
625  {
626  if (*V_ARRAYREF(pVarg))
627  hres = SafeArrayDestroy(*V_ARRAYREF(pVarg));
628  }
629  else if (V_ARRAY(pVarg))
630  hres = SafeArrayDestroy(V_ARRAY(pVarg));
631  }
632  break;
633  }
634 
635  V_VT(pVarg) = VT_EMPTY;
636  return hres;
637 }
#define V_ARRAY(A)
Definition: oleauto.h:222
#define V_ISBYREF(A)
Definition: oleauto.h:217
#define V_UNKNOWNREF(A)
Definition: oleauto.h:282
#define V_ISARRAY(A)
Definition: oleauto.h:218
#define V_ARRAYREF(A)
Definition: oleauto.h:223
#define __tagBRECORD
Definition: compat.h:2023
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI SafeArrayDestroy(SAFEARRAY *psa)
Definition: safearray.c:1349
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
#define V_VT(A)
Definition: oleauto.h:211
#define V_UNKNOWN(A)
Definition: oleauto.h:281
#define V_BSTR(A)
Definition: oleauto.h:226
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
#define V_UNION(A, B)
Definition: oleauto.h:212
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:274
#define V_VARIANTREF(A)
Definition: oleauto.h:283
static HRESULT VARIANT_ValidateType(VARTYPE vt)
Definition: variant.c:537
#define V_BSTRREF(A)
Definition: oleauto.h:227

Referenced by ITypeInfo_fnInvoke().