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.

315 lines
8.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: dbrstrct.cxx
  7. //
  8. // Contents: C++ Wrapper classes for DBCOMMANDTREE boolean operators
  9. //
  10. // Classes: CDbRestriction
  11. // CDbNodeRestriction
  12. // CDbNotRestriction
  13. // CDbPropBaseRestriction
  14. // CDbPropertyRestriction
  15. // CDbContentBaseRestriction
  16. // CDbContentRestriction
  17. // CDbNatLangContentRestriction
  18. //
  19. // History: 6-06-95 srikants Created
  20. //
  21. //----------------------------------------------------------------------------
  22. #include "pch.cxx"
  23. #pragma hdrstop
  24. extern const GUID DBGUID_LIKE_OFS;
  25. //+---------------------------------------------------------------------------
  26. //
  27. // Method: CDbPropBaseRestriction::SetProperty
  28. //
  29. // Synopsis: Set property node on a content restriction
  30. //
  31. // Arguments: [Property] - property identifier to be set on node
  32. //
  33. // Returns:
  34. //
  35. // History: 6-11-95 srikants Created
  36. //
  37. // Notes:
  38. //
  39. //----------------------------------------------------------------------------
  40. BOOL CDbPropBaseRestriction::SetProperty( DBID const & Property )
  41. {
  42. //
  43. // If a child property node already exists, we must delete it
  44. //
  45. CDbCmdTreeNode * pChild = GetFirstChild();
  46. Win4Assert( 0 == pChild || pChild->IsColumnName() );
  47. BOOL fSuccess = TRUE;
  48. if ( 0 != pChild && pChild->IsColumnName())
  49. {
  50. RemoveFirstChild( );
  51. delete pChild;
  52. }
  53. XPtr<CDbColumnNode> xProperty( new CDbColumnNode( Property, TRUE ) );
  54. if ( !xProperty.IsNull() && xProperty->IsValid() )
  55. {
  56. InsertChild( xProperty.GetPointer() );
  57. xProperty.Acquire();
  58. }
  59. else
  60. fSuccess = FALSE;
  61. return fSuccess;
  62. }
  63. //+---------------------------------------------------------------------------
  64. //
  65. // Method: CDbPropBaseRestriction::SetProperty
  66. //
  67. // Synopsis: Set property node on a content restriction
  68. //
  69. // Arguments: [Property] - property identifier to be set on node
  70. //
  71. // Returns:
  72. //
  73. // History: 6-11-95 srikants Created
  74. //
  75. // Notes:
  76. //
  77. //----------------------------------------------------------------------------
  78. BOOL CDbPropBaseRestriction::SetProperty( CDbColumnNode const & Property )
  79. {
  80. //
  81. // If a child node already exists, we must delete it
  82. //
  83. CDbCmdTreeNode * pChild = GetFirstChild();
  84. Win4Assert( 0 == pChild || pChild->IsColumnName() );
  85. if ( 0 != pChild && pChild->IsColumnName() )
  86. {
  87. RemoveFirstChild();
  88. delete pChild;
  89. }
  90. BOOL fSuccess = TRUE;
  91. XPtr<CDbColumnNode> xProperty( new CDbColumnNode( Property ) );
  92. if ( !xProperty.IsNull() && xProperty->IsValid() )
  93. {
  94. InsertChild( xProperty.GetPointer() );
  95. xProperty.Acquire();
  96. }
  97. else
  98. fSuccess = FALSE;
  99. return fSuccess;
  100. }
  101. //+---------------------------------------------------------------------------
  102. //
  103. // Method: CDbPropertyRestriction::CDbPropertyRestriction
  104. //
  105. // Synopsis:
  106. //
  107. // Arguments: [relop] - relation operator
  108. // [Property] - property identifier to be set on node
  109. // [prval] -
  110. //
  111. // Returns:
  112. //
  113. // History: 6-07-95 srikants Created
  114. //
  115. // Notes:
  116. //
  117. //----------------------------------------------------------------------------
  118. CDbPropertyRestriction::CDbPropertyRestriction( DBCOMMANDOP relop,
  119. DBID const & Property,
  120. CStorageVariant const & prval )
  121. {
  122. SetRelation( relop );
  123. SetProperty( Property );
  124. SetValue( prval );
  125. if (DBOP_like == relop)
  126. _SetLikeRelation();
  127. else
  128. SetValueType(DBVALUEKIND_I4);
  129. SetWeight(0);
  130. }
  131. //+---------------------------------------------------------------------------
  132. //
  133. // Method: CDbPropertyRestriction::IsCIDialect, private
  134. //
  135. // Synopsis: Set up for a DBOP_like node.
  136. //
  137. // Arguments: -none-
  138. //
  139. // Returns: BOOL - TRUE if value is the GUID for the CI regexp dialect
  140. //
  141. // History: 26 Jul 1995 AlanW Created
  142. //
  143. // Notes:
  144. //
  145. //----------------------------------------------------------------------------
  146. BOOL CDbPropertyRestriction::IsCIDialect( )
  147. {
  148. if ( DBVALUEKIND_LIKE == wKind )
  149. {
  150. CDbLike * pLike = (CDbLike *) value.pdblikeValue;
  151. if ( 0 != pLike )
  152. return DBGUID_LIKE_OFS == pLike->GetDialect();
  153. }
  154. return FALSE;
  155. }
  156. //+---------------------------------------------------------------------------
  157. //
  158. // Method: CDbPropertyRestriction::_FindOrAddValueNode
  159. //
  160. // Synopsis:
  161. //
  162. // Returns:
  163. //
  164. // History: 6-11-95 srikants Created
  165. //
  166. // Notes:
  167. //
  168. //----------------------------------------------------------------------------
  169. CDbScalarValue * CDbPropertyRestriction::_FindOrAddValueNode()
  170. {
  171. CDbScalarValue * pValue = _FindValueNode();
  172. if ( 0 == pValue )
  173. {
  174. pValue = new CDbScalarValue();
  175. if ( 0 != pValue )
  176. AppendChild( pValue );
  177. }
  178. return pValue;
  179. }
  180. //+---------------------------------------------------------------------------
  181. //
  182. // Method: CDbContentRestriction::CDbContentRestriction
  183. //
  184. // Synopsis:
  185. //
  186. // Arguments: [pwcsPhrase] -
  187. // [Property] - property identifier to be set on node
  188. // [ulGenerateMethod] -
  189. // [lcid] -
  190. //
  191. // Returns:
  192. //
  193. // History: 6-11-95 srikants Created
  194. //
  195. // Notes:
  196. //
  197. //----------------------------------------------------------------------------
  198. CDbContentRestriction::CDbContentRestriction(
  199. const WCHAR * pwcsPhrase,
  200. CDbColumnNode const & Property,
  201. ULONG ulGenerateMethod,
  202. LCID lcid ) :
  203. CDbContentBaseRestriction( DBOP_content,
  204. ulGenerateMethod, MAX_QUERY_RANK, lcid, pwcsPhrase )
  205. {
  206. if ( IsContentValid() )
  207. SetProperty( Property );
  208. }
  209. //+---------------------------------------------------------------------------
  210. //
  211. // Method: CDbContentRestriction::CDbContentRestriction
  212. //
  213. // Synopsis:
  214. //
  215. // Arguments: [pwcsPhrase] -
  216. // [Property] - property identifier to be set on node
  217. // [ulGenerateMethod] -
  218. // [lcid] -
  219. //
  220. // Returns:
  221. //
  222. // History: 3-20-96 dlee Created
  223. //
  224. // Notes:
  225. //
  226. //----------------------------------------------------------------------------
  227. CDbContentRestriction::CDbContentRestriction(
  228. const WCHAR * pwcsPhrase,
  229. DBID const & Property,
  230. ULONG ulGenerateMethod,
  231. LCID lcid ) :
  232. CDbContentBaseRestriction( DBOP_content,
  233. ulGenerateMethod, MAX_QUERY_RANK, lcid, pwcsPhrase )
  234. {
  235. if ( IsContentValid() )
  236. SetProperty( Property );
  237. }
  238. //+---------------------------------------------------------------------------
  239. //
  240. // Method: CDbNatLangRestriction::CdbNatLangRestriction
  241. //
  242. // Synopsis:
  243. //
  244. // Arguments: [pwcsPhrase] -
  245. // [Property] - property identifier to be set on node
  246. // [lcid] -
  247. //
  248. // Returns:
  249. //
  250. // History: 6-11-95 srikants Created
  251. //
  252. // Notes:
  253. //
  254. //----------------------------------------------------------------------------
  255. CDbNatLangRestriction::CDbNatLangRestriction(
  256. const WCHAR * pwcsPhrase,
  257. CDbColumnNode const & Property,
  258. LCID lcid )
  259. : CDbContentBaseRestriction( DBOP_content_freetext, GENERATE_METHOD_EXACT,
  260. MAX_QUERY_RANK, lcid, pwcsPhrase )
  261. {
  262. if ( IsContentValid() )
  263. SetProperty( Property );
  264. }
  265. CDbNatLangRestriction::CDbNatLangRestriction(
  266. const WCHAR * pwcsPhrase,
  267. DBID const & Property,
  268. LCID lcid )
  269. : CDbContentBaseRestriction( DBOP_content_freetext, GENERATE_METHOD_EXACT,
  270. MAX_QUERY_RANK, lcid, pwcsPhrase )
  271. {
  272. if ( IsContentValid() )
  273. SetProperty( Property );
  274. }