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.

67 lines
2.1 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 1999
  5. *
  6. * File: variant.h
  7. *
  8. * Contents: Interface file for various VARIANT helper functions
  9. *
  10. * History: 19-Nov-1999 jeffro Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #pragma once
  14. #ifndef VARIANT_H_INCLUDED
  15. #define VARIANT_H_INCLUDED
  16. /*+-------------------------------------------------------------------------*
  17. * ConvertByRefVariantToByValue
  18. *
  19. * VBScript will has two syntaxes for calling dispinterfaces:
  20. *
  21. * 1. obj.Method (arg)
  22. * 2. obj.Method arg
  23. *
  24. * The first syntax will pass arg by value, which out dispinterfaces will
  25. * be able to handle. If Method takes a BSTR argument, the VARIANT that
  26. * arrives at Method will be of type VT_BSTR.
  27. *
  28. * The second syntax will pass arg by reference. In this case Method will
  29. * receive a VARIANT of type (VT_VARIANT | VT_BYREF). The VARIANT that is
  30. * referenced will be of type VT_BSTR.
  31. *
  32. * This function will dereference the VARIANT and return the direct pointer
  33. * in pVar. Calling this function on a VARIANT that is not VT_BYREF is
  34. * harmless.
  35. *--------------------------------------------------------------------------*/
  36. inline VARIANT* ConvertByRefVariantToByValue (VARIANT* pVar)
  37. {
  38. while ((pVar != NULL) && (V_VT(pVar) == (VT_VARIANT | VT_BYREF)))
  39. {
  40. pVar = V_VARIANTREF(pVar);
  41. }
  42. return (pVar);
  43. }
  44. /*+-------------------------------------------------------------------------*
  45. * IsOptionalParamMissing
  46. *
  47. * Returns true if an optional argument to an Automation method is left
  48. * blank. This is indicated by a type of VT_ERROR with a value of
  49. * DISP_E_PARAMNOTFOUND.
  50. *
  51. * This should be moved to a header.
  52. *--------------------------------------------------------------------------*/
  53. inline bool IsOptionalParamMissing (const VARIANT& var)
  54. {
  55. return ((V_VT(&var) == VT_ERROR) && (V_ERROR(&var) == DISP_E_PARAMNOTFOUND));
  56. }
  57. #endif /* VARIANT_H_INCLUDED */