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.

168 lines
5.1 KiB

  1. #if (!defined(BUILD_FOR_NT40))
  2. #pragma once
  3. //---------------------------------------------------------------------------
  4. //
  5. // @class CDBProperties | Maintenance of properties and their values.
  6. //
  7. //---------------------------------------------------------------------------
  8. class CDBProperties : INHERIT_TRACKING
  9. {
  10. public:
  11. //constructor
  12. CDBProperties();
  13. //destructor
  14. ~CDBProperties();
  15. //Gets a property set given its GUID.
  16. DBPROPSET* GetPropertySet(const GUID& guid) const;
  17. //Gets a property set given its index into the array of property sets.
  18. DBPROPSET* GetPropertySet(ULONG iPropSet) const
  19. { return ( GetPropertySet(_aPropSets[iPropSet].guidPropertySet) ); }
  20. //Gets info about a property set given its GUID.
  21. DBPROPINFOSET* GetPropertyInfoSet(const GUID& guid) const;
  22. //Gest info about a property set given its index into the array
  23. //of property set info structs.
  24. DBPROPINFOSET* GetPropertyInfoSet(ULONG iPropInfoSet) const
  25. {
  26. return ( GetPropertyInfoSet(
  27. _aPropInfoSets[iPropInfoSet].guidPropertySet) );
  28. }
  29. //Copies property set given its GUID to another property set.
  30. HRESULT CopyPropertySet(const GUID& guid,
  31. DBPROPSET* pPropSetDst) const;
  32. //Copies a property set given its index (into the array of property sets)
  33. //to another property set.
  34. HRESULT CopyPropertySet(ULONG iPropSet,
  35. DBPROPSET* pPropSetDst) const
  36. {
  37. return ( CopyPropertySet(
  38. _aPropSets[iPropSet].guidPropertySet,
  39. pPropSetDst) );
  40. }
  41. //Copies info of a property set to another, given the GUID.
  42. HRESULT CopyPropertyInfoSet(
  43. const GUID& guid,
  44. DBPROPINFOSET* pPropInfoSetDst,
  45. OLECHAR** ppDescBuffer,
  46. ULONG_PTR *pcchDesc,
  47. ULONG_PTR *pichCurrent) const;
  48. //Copies info of a property set to another, given the index into the
  49. //array of property set info structs.
  50. HRESULT CopyPropertyInfoSet(
  51. ULONG iPropInfoSet,
  52. DBPROPINFOSET* pPropInfoSetDst,
  53. OLECHAR** ppDescBuffer,
  54. ULONG_PTR *pcchDesc,
  55. ULONG_PTR *pichCurrent) const
  56. {
  57. RRETURN ( CopyPropertyInfoSet(
  58. _aPropInfoSets[iPropInfoSet].guidPropertySet,
  59. pPropInfoSetDst,
  60. ppDescBuffer,
  61. pcchDesc,
  62. pichCurrent) );
  63. }
  64. //Gets a property given the set's GUID and the property id.
  65. const DBPROP* GetProperty(const GUID& guid, DBPROPID id) const;
  66. //Gets info about a property given the set's GUID and the property id.
  67. const DBPROPINFO UNALIGNED* GetPropertyInfo(const GUID& guid, DBPROPID id) const;
  68. //Sets a property given the GUID of the set and the property
  69. //This flavor takes the description string directly.
  70. HRESULT SetProperty(const GUID& guid,
  71. const DBPROP& prop,
  72. BOOL fAddNew,
  73. PWSTR pwszDesc);
  74. //Sets info of a property given the set's GUID and the info.
  75. HRESULT SetPropertyInfo(const GUID& guid,
  76. const DBPROPINFO& prop);
  77. //Gets the number of property sets this object is currently managing.
  78. ULONG GetNPropSets() const { return ( _cPropSets ); }
  79. //Loads the description contained in a resource descriptor.
  80. int LoadDescription(ULONG uID,
  81. PWSTR lpBuffer,
  82. ULONG cchBufferMax) const;
  83. //Copies property descriptions to a buffer, given the
  84. //set of property info structures.
  85. HRESULT CopyPropertyDescriptions(
  86. DBPROPINFOSET* pPropInfoSet,
  87. WCHAR** ppBuf,
  88. ULONG_PTR* pcchBuffer,
  89. ULONG_PTR* pichCurrent) const;
  90. //Validates the given property sets. A helper function
  91. //used while setting property sets.
  92. static HRESULT VerifySetPropertiesArgs(
  93. ULONG cPropertySets,
  94. DBPROPSET rgPropertySets[]);
  95. //Checks and initializes property sets. A helper function
  96. //used while getting property sets.
  97. static HRESULT CheckAndInitPropArgs
  98. (
  99. ULONG cPropertySets,
  100. const DBPROPIDSET rgPropertySets[],
  101. ULONG *pcPropertySets,
  102. void **prgPropertySets,
  103. BOOL *pfPropInError,
  104. BOOL *pfPropSpecial
  105. );
  106. private:
  107. ULONG _cPropSets; // number of property sets
  108. DBPROPSET* _aPropSets; // array of property sets
  109. ULONG _cPropInfoSets; // number of property info sets
  110. DBPROPINFOSET* _aPropInfoSets; // array of property info sets
  111. NO_COPY(CDBProperties);
  112. };
  113. //--- D E F I N E S, M A C R O S A N D I N L I N E F U N C T I O N S ----
  114. // Increment of property array allocation
  115. const ULONG C_PROP_INCR = 12L;
  116. const ULONG CCHAR_AVERAGE_PROP_STR_LENGTH = 40L;
  117. const ULONG CCHAR_MAX_PROP_STR_LENGTH = 100L;
  118. inline BOOL GoodPropOption
  119. (
  120. DBPROPOPTIONS dwOptions
  121. )
  122. {
  123. return ( (dwOptions == DBPROPOPTIONS_REQUIRED ||
  124. dwOptions == DBPROPOPTIONS_SETIFCHEAP) );
  125. }
  126. inline BOOL IsColIDNULL
  127. (
  128. DBID colid
  129. )
  130. { return ( (colid.eKind == 0 && colid.uName.pwszName == NULL) ); }
  131. BOOL VariantsEqual
  132. (
  133. VARIANT *pvar1,
  134. VARIANT *pvar2
  135. );
  136. #endif