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.

113 lines
3.5 KiB

  1. //--------------------------------------------------------------------
  2. // Microsoft OLE-DB Monarch
  3. //
  4. // Copyright 1997 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // @doc
  7. //
  8. // @module colname.h |
  9. //
  10. // Contains utility functions for maintaining property lists (symbol table?)
  11. //
  12. // @rev 0 | 12-Feb-97 | v-charca | Created
  13. // 1 | 24-Oct-98 | danleg | cleanup
  14. //
  15. #ifndef __PROPERTYLIST_INCL__
  16. #define __PROPERTYLIST_INCL__
  17. //--------------------------------------------------------------------
  18. // @func Makes a new copy of UNICODE string
  19. // @side Allocates enough bytes from memory object to hold string
  20. // @rdesc Pointer to new UNICODE string
  21. inline WCHAR * CopyString( WCHAR const * pwc )
  22. {
  23. unsigned c = wcslen( pwc ) + 1;
  24. WCHAR *pwcNew = new WCHAR[c];
  25. RtlCopyMemory( pwcNew, pwc, c * sizeof WCHAR );
  26. return pwcNew;
  27. }
  28. //--------------------------------------------------------------------
  29. // @func Makes a new copy of UNICODE string
  30. // @side Allocates enough bytes from memory object to hold string
  31. // @rdesc Pointer to new UNICODE string
  32. inline LPWSTR CoTaskStrDup
  33. (
  34. const WCHAR * pwszOrig,
  35. UINT cLen
  36. )
  37. {
  38. UINT cBytes = (cLen+1) * sizeof WCHAR;
  39. WCHAR* pwszCopy = (WCHAR *) CoTaskMemAlloc( cBytes );
  40. if ( 0 != pwszCopy )
  41. RtlCopyMemory( pwszCopy, pwszOrig, cBytes );
  42. return pwszCopy;
  43. }
  44. //--------------------------------------------------------------------
  45. // @func Makes a new copy of UNICODE string
  46. // @side Allocates enough bytes from memory object to hold string
  47. // @rdesc Pointer to new UNICODE string
  48. inline LPWSTR CoTaskStrDup
  49. (
  50. const WCHAR * pwszOrig
  51. )
  52. {
  53. return CoTaskStrDup( pwszOrig, wcslen(pwszOrig) );
  54. }
  55. //--------------------------------------------------------------------
  56. typedef struct tagHASHENTRY
  57. {
  58. LPWSTR wcsFriendlyName;
  59. UINT wHashValue;
  60. DWORD dbType;
  61. DBID dbCol;
  62. tagHASHENTRY* pNextHashEntry;
  63. } HASHENTRY;
  64. class CPropertyList
  65. {
  66. public: //@access public functions
  67. CPropertyList(CPropertyList** ppGlobalPropertyList);
  68. ~CPropertyList();
  69. HRESULT LookUpPropertyName( LPWSTR wszPropertyName,
  70. DBCOMMANDTREE** ppct,
  71. DBTYPE* pdbType );
  72. HRESULT SetPropertyEntry ( LPWSTR pwszFriendlyName,
  73. DWORD dbType,
  74. GUID guidPropset,
  75. DBKIND eKind,
  76. LPWSTR pwszPropName,
  77. BOOL fGlobal );
  78. CIPROPERTYDEF* GetPropertyTable( UINT* pcSize );
  79. void DeletePropertyTable( CIPROPERTYDEF* pCiPropTable,
  80. UINT cSize );
  81. protected: //@access protected functions
  82. HASHENTRY* FindPropertyEntry( LPWSTR wszPropertyName,
  83. UINT *puHashValue );
  84. HASHENTRY* GetPropertyEntry( LPWSTR wszPropertyName,
  85. UINT *puHashValue );
  86. inline UINT GetHashValue( LPWSTR wszPropertyName );
  87. protected: //@access protected data
  88. XArray<HASHENTRY*> m_aBucket; // Array of pointers to hash buckets
  89. int m_cMaxBucket; // Number of hash buckets (PRIME!)
  90. CPropertyList** m_ppGlobalPropertyList; // Pointer to the global property list
  91. };
  92. #endif