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.

208 lines
6.4 KiB

  1. //----------------------------------------------------------------------------
  2. // Microsoft OLE DB Implementation For Index Server
  3. // (C) Copyright 1997 By Microsoft Corporation.
  4. //
  5. // @doc
  6. //
  7. // @module PTPROPS.H |
  8. //
  9. // @rev 1 | 10-13-97 | Briants | Created
  10. //
  11. // Includes ------------------------------------------------------------------
  12. #ifndef _PTPROPS_H_
  13. #define _PTPROPS_H_
  14. const ULONG MAX_CCH_COLUMNNAME = 128; // per Section 3.1 of spec
  15. const ULONG CCH_CIRESTRICTION_INCREMENT = 128;
  16. const ULONG CB_SCOPE_DATA_BUFFER_INC = 512;
  17. const ULONG SCOPE_BUFFERS_INCREMENT = 5;
  18. const ULONG UNUSED_OFFSET = (ULONG)-1;
  19. #define MAX_ERRORS 2
  20. class CScopeData
  21. {
  22. private: //@access Private Data Members
  23. LONG m_cRef;
  24. ULONG m_cScope;
  25. ULONG m_cMaxScope;
  26. ULONG* m_rgulDepths;
  27. ULONG* m_rgCatalogOffset;
  28. ULONG* m_rgScopeOffset;
  29. ULONG* m_rgMachineOffset;
  30. ULONG m_cbData;
  31. ULONG m_cbMaxData;
  32. BYTE* m_rgbData;
  33. private: //@access Private Member Functions
  34. HRESULT CacheData(LPVOID pData, ULONG cb, ULONG* pulOffset);
  35. public:
  36. CScopeData();
  37. ~CScopeData();
  38. HRESULT FInit(LPCWSTR pcwszMachine);
  39. HRESULT Reset(void);
  40. // Handle sharing of this object
  41. ULONG AddRef(void);
  42. ULONG Release(void);
  43. HRESULT GetData(ULONG uPropId, VARIANT* pvValue, LPCWSTR pcwszCatalog = NULL);
  44. HRESULT SetTemporaryMachine(LPWSTR pwszMachine, ULONG cch);
  45. HRESULT SetTemporaryCatalog(LPWSTR pwszCatalog, ULONG cch);
  46. HRESULT SetTemporaryScope(LPWSTR pwszScope, ULONG cch);
  47. HRESULT IncrementScopeCount();
  48. //--------------------------------------------------------------------
  49. // @mfunc Stores the traversl depth used for setting scope properties
  50. // in the compiler environment.
  51. //
  52. // @rdesc none
  53. //
  54. inline void SetTemporaryDepth(
  55. ULONG ulDepth // @parm IN | search depth
  56. )
  57. {
  58. m_rgulDepths[m_cScope] = ulDepth;
  59. }
  60. //--------------------------------------------------------------------
  61. // @func Masks the traversal depth used for setting scope
  62. // properties in the compiler environment. This is used
  63. // to specify virtual or physical paths.
  64. //
  65. // @rdesc none
  66. //
  67. inline void MaskTemporaryDepth(
  68. ULONG ulMask // @parm IN | search mask (virtual or physical)
  69. )
  70. {
  71. m_rgulDepths[m_cScope] |= ulMask;
  72. }
  73. };
  74. // CImpIParserTreeProperties Object
  75. class CImpIParserTreeProperties : public IParserTreeProperties
  76. {
  77. private:
  78. LONG m_cRef;
  79. //@cmember
  80. CScopeData* m_pCScopeData;
  81. LPWSTR m_pwszCatalog;
  82. HRESULT m_LastHR;
  83. UINT m_iErrOrd;
  84. WCHAR* m_pwszErrParams[MAX_ERRORS];
  85. ULONG m_cErrParams;
  86. // Have buffer with space for max column name +
  87. // a space before the column name.
  88. WCHAR m_rgwchCiColumn[MAX_CCH_COLUMNNAME + 2];
  89. ULONG m_cchMaxRestriction;
  90. ULONG m_cchRestriction;
  91. LPWSTR m_pwszRestriction;
  92. LPWSTR m_pwszRestrictionAppendPtr;
  93. bool m_fLeftParen;
  94. BOOL m_fDesc; // make the sort direction "sticky"
  95. DBTYPE m_dbType;
  96. DBCOMMANDTREE* m_pctContainsColumn;
  97. public:
  98. // CTOR and DTOR
  99. CImpIParserTreeProperties();
  100. ~CImpIParserTreeProperties();
  101. HRESULT FInit(LPCWSTR pwszCatalog, LPCWSTR pwszMachine);
  102. STDMETHODIMP QueryInterface(
  103. REFIID riid, LPVOID* ppVoid);
  104. STDMETHODIMP_(ULONG) Release (void);
  105. STDMETHODIMP_(ULONG) AddRef (void);
  106. STDMETHODIMP GetProperties(
  107. ULONG eParseProp, VARIANT* vParseProp);
  108. void SetCiColumn(LPWSTR pwszColumn);
  109. HRESULT AppendCiRestriction(LPWSTR pwsz, ULONG cch);
  110. HRESULT UseCiColumn(WCHAR wch);
  111. HRESULT CreateNewScopeDataObject(LPCWSTR pwszMachine);
  112. void ReplaceScopeDataPtr(CScopeData* pCScopeData);
  113. // Inline Functions
  114. inline CScopeData* GetScopeDataPtr()
  115. { return m_pCScopeData; }
  116. inline void CiNeedLeftParen(void)
  117. { m_fLeftParen = true; }
  118. inline void SetNumErrParams(UINT cErrParams)
  119. { m_cErrParams = cErrParams; }
  120. inline UINT GetNumErrParams()
  121. { return m_cErrParams; }
  122. inline void SetErrorHResult(HRESULT hr, UINT iErrOrd=0)
  123. {
  124. m_LastHR = hr;
  125. m_iErrOrd = iErrOrd;
  126. m_cErrParams = 0;
  127. }
  128. inline void SetErrorToken(const WCHAR* pwstr)
  129. {
  130. assert(m_cErrParams < MAX_ERRORS); // can't happen
  131. WCHAR * pwc = CopyString( pwstr );
  132. // Truncate long errors since FormatMessage will fail otherwise
  133. if ( wcslen( pwc ) >= (MAX_PATH-1) )
  134. pwc[ MAX_PATH-1] = 0;
  135. m_pwszErrParams[m_cErrParams++] = pwc;
  136. }
  137. inline HRESULT GetErrorHResult()
  138. { return m_LastHR; }
  139. inline UINT GetErrorOrdinal()
  140. { return m_iErrOrd; }
  141. inline void FreeErrorDescriptions()
  142. {
  143. for (UINT i = 0; i < m_cErrParams; i++)
  144. delete [] m_pwszErrParams[i];
  145. }
  146. inline DBTYPE GetDBType()
  147. { return m_dbType; }
  148. inline void SetDBType(DBTYPE dbType)
  149. { m_dbType = dbType; }
  150. inline BOOL GetSortDesc()
  151. { return m_fDesc; }
  152. inline void SetSortDesc(BOOL fDesc)
  153. { m_fDesc = fDesc; }
  154. inline DBCOMMANDTREE* GetContainsColumn()
  155. { return m_pctContainsColumn; }
  156. inline void SetContainsColumn(DBCOMMANDTREE* pct)
  157. { m_pctContainsColumn = pct; }
  158. }; // End of Class
  159. #endif // _PTPROPS_H_