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.

137 lines
2.9 KiB

  1. /*
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. */
  4. #ifndef __SDP_UNSIGNED_INTEGRAL_TYPE_SAFEARRAY__
  5. #define __SDP_UNSIGNED_INTEGRAL_TYPE_SAFEARRAY__
  6. #include "sdpcommo.h"
  7. template <class BASE, class T, class TLIST>
  8. class _DllDecl SDP_UITYPE_SAFEARRAY :
  9. protected SDP_SAFEARRAY_WRAP_EX<T, TLIST>
  10. {
  11. public:
  12. inline SDP_UITYPE_SAFEARRAY(
  13. IN TLIST &SdpUitypeList
  14. );
  15. inline HRESULT GetSafeArray(
  16. OUT VARIANT *UitypeVariant
  17. );
  18. inline HRESULT SetSafeArray(
  19. IN VARIANT &UitypeVariant
  20. );
  21. protected:
  22. VARTYPE m_VarType[1];
  23. BASE m_BaseValue;
  24. virtual BOOL Get(
  25. IN T &ListMember,
  26. IN ULONG NumEntries,
  27. IN void **Element,
  28. OUT HRESULT &HResult
  29. );
  30. virtual BOOL Set(
  31. IN T &ListMember,
  32. IN ULONG NumEntries,
  33. IN void ***Element,
  34. OUT HRESULT &HResult
  35. );
  36. };
  37. // the vartype is initialized in the deriving class
  38. template <class BASE, class T, class TLIST>
  39. inline
  40. SDP_UITYPE_SAFEARRAY<BASE, T, TLIST>::SDP_UITYPE_SAFEARRAY(
  41. IN TLIST &SdpUitypeList
  42. )
  43. : SDP_SAFEARRAY_WRAP_EX<T, TLIST>(SdpUitypeList)
  44. {}
  45. template <class BASE, class T, class TLIST>
  46. inline HRESULT
  47. SDP_UITYPE_SAFEARRAY<BASE, T, TLIST>::GetSafeArray(
  48. OUT VARIANT *UitypeVariant
  49. )
  50. {
  51. VARIANT *VariantArray[] = {UitypeVariant};
  52. return SDP_SAFEARRAY_WRAP::GetSafeArrays(
  53. m_TList.GetSize(),
  54. sizeof(VariantArray)/sizeof(VARIANT *),
  55. m_VarType,
  56. VariantArray
  57. );
  58. }
  59. template <class BASE, class T, class TLIST>
  60. inline HRESULT
  61. SDP_UITYPE_SAFEARRAY<BASE, T, TLIST>::SetSafeArray(
  62. IN VARIANT &UitypeVariant
  63. )
  64. {
  65. VARIANT *VariantArray[] = {&UitypeVariant};
  66. return SDP_SAFEARRAY_WRAP::SetSafeArrays(
  67. sizeof(VariantArray)/sizeof(VARIANT *),
  68. m_VarType,
  69. VariantArray
  70. );
  71. }
  72. template <class BASE, class T, class TLIST>
  73. BOOL
  74. SDP_UITYPE_SAFEARRAY<BASE, T, TLIST>::Get(
  75. IN T &ListMember,
  76. IN ULONG NumEntries,
  77. IN void **Element,
  78. OUT HRESULT &HResult
  79. )
  80. {
  81. ASSERT(1 == NumEntries);
  82. m_BaseValue = ListMember.GetValue();
  83. Element[0] = &m_BaseValue;
  84. return TRUE;
  85. }
  86. template <class BASE, class T, class TLIST>
  87. BOOL
  88. SDP_UITYPE_SAFEARRAY<BASE, T, TLIST>::Set(
  89. IN T &ListMember,
  90. IN ULONG NumEntries,
  91. IN void ***Element,
  92. OUT HRESULT &HResult
  93. )
  94. {
  95. ASSERT(1 == NumEntries);
  96. ASSERT(NULL != Element[0]);
  97. ListMember.SetValueAndFlag(*((BASE *)Element[0]));
  98. return TRUE;
  99. }
  100. #endif // __SDP_UNSIGNED_INTEGRAL_TYPE_SAFEARRAY__