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.

85 lines
2.2 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1997, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // PropSet.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file describes the class DBPropertySet.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 10/30/1997 Original version.
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #ifndef _PROPSET_H_
  19. #define _PROPSET_H_
  20. ///////////////////////////////////////////////////////////////////////////////
  21. //
  22. // CLASS
  23. //
  24. // DBPropertySet<N>
  25. //
  26. // DESCRIPTION
  27. //
  28. // This class provides a very basic wrapper around an OLE DB property set.
  29. // The template parameter 'N' specifies the capacity of the set.
  30. //
  31. ///////////////////////////////////////////////////////////////////////////////
  32. template <size_t N>
  33. struct DBPropertySet : DBPROPSET
  34. {
  35. DBPropertySet(const GUID& guid)
  36. {
  37. guidPropertySet = guid;
  38. cProperties = 0;
  39. rgProperties = DBProperty;
  40. }
  41. ~DBPropertySet()
  42. {
  43. for (size_t i = 0; i<cProperties; i++)
  44. VariantClear(&DBProperty[i].vValue);
  45. }
  46. bool AddProperty(DWORD dwPropertyID, LPCWSTR szValue)
  47. {
  48. if (cProperties >= N) return false;
  49. DBProperty[cProperties].dwPropertyID = dwPropertyID;
  50. DBProperty[cProperties].dwOptions = DBPROPOPTIONS_REQUIRED;
  51. DBProperty[cProperties].colid = DB_NULLID;
  52. DBProperty[cProperties].vValue.vt = VT_BSTR;
  53. DBProperty[cProperties].vValue.bstrVal = SysAllocString(szValue);
  54. if (DBProperty[cProperties].vValue.bstrVal == NULL) return false;
  55. cProperties++;
  56. return true;
  57. }
  58. bool AddProperty(DWORD dwPropertyID, long lValue)
  59. {
  60. if (cProperties >= N) return false;
  61. DBProperty[cProperties].dwPropertyID = dwPropertyID;
  62. DBProperty[cProperties].dwOptions = DBPROPOPTIONS_REQUIRED;
  63. DBProperty[cProperties].colid = DB_NULLID;
  64. DBProperty[cProperties].vValue.vt = VT_I4;
  65. DBProperty[cProperties].vValue.lVal = lValue;
  66. cProperties++;
  67. return true;
  68. }
  69. DBPROP DBProperty[N];
  70. };
  71. #endif // _PROPSET_H_