- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
//+-------------------------------------------------------------------------
//
// Function: GetNumberOfType
// SetNumberOfType
//
// Synopsis: Helpers to get/set an integer value of given variant type
// by dereferencing a pointer
//
// pv - pointer to dereference
// vt - variant type
//
//--------------------------------------------------------------------------
// BUGBUG: The VC 5 compiler flags this as an error because VT_BOOL4 is not
// a valid VARENUM value. Disable the warning for now.
#pragma warning(disable:4063) // case '254' is not a valid value for switch of enum 'VARENUM'
long
GetNumberOfType (void * pv, VARENUM vt)
{
switch(vt)
{
case VT_I2:
case VT_BOOL:
return * (SHORT*) pv;
case VT_I4:
case VT_BOOL4:
return * (LONG*) pv;
default:
Assert(FALSE);
return 0;
}
}
void
SetNumberOfType (void * pv, VARENUM vt, long l)
{
switch(vt)
{
case VT_BOOL:
l = l ? VB_TRUE : VB_FALSE;
// vvvvvvvvvvv FALL THROUGH vvvvvvvvvvvvv
case VT_I2:
Assert(l >= SHRT_MIN && l <= SHRT_MAX);
* (SHORT*) pv = SHORT(l);
break;
case VT_BOOL4:
l = l ? VB_TRUE : VB_FALSE;
// vvvvvvvvvvv FALL THROUGH vvvvvvvvvvvvv
case VT_I4:
* (LONG_UNALIGNED *) pv = l;
break;
default:
Assert(FALSE);
}
}
CCAHA9I_CPAHIHA 31.08.2018 16:00 # −1
HoBoroDHuu_xyu 02.01.2020 10:46 # −1
AnalBoy 03.01.2020 00:36 # 0