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.

1911 lines
36 KiB

  1. // (C) 1999-2001 Microsoft Corporation
  2. #ifndef __DNF_TREE_H
  3. #define __DNF_TREE_H
  4. /******************************************************************************
  5. *
  6. * Name:
  7. *
  8. *
  9. * Description:
  10. *
  11. *
  12. *****************************************************************************/
  13. #include <stdio.h>
  14. #include <wmiutils.h>
  15. #include "ProvTree.h"
  16. /******************************************************************************
  17. *
  18. * Name:
  19. *
  20. *
  21. * Description:
  22. *
  23. *
  24. *****************************************************************************/
  25. enum WmiTriState
  26. {
  27. State_False = 0 ,
  28. State_True = 1 ,
  29. State_Error = 0xFFFFFFFF
  30. } ;
  31. /******************************************************************************
  32. *
  33. * Name:
  34. *
  35. *
  36. * Description:
  37. *
  38. *
  39. *****************************************************************************/
  40. #define TypeId_WmiOrNode 1
  41. #define TypeId_WmiAndNode 2
  42. #define TypeId_WmiNotNode 3
  43. #define TypeId_WmiOperatorNode 4
  44. #define TypeId_WmiOperatorEqualNode 5
  45. #define TypeId_WmiOperatorNotEqualNode 6
  46. #define TypeId_WmiOperatorEqualOrGreaterNode 7
  47. #define TypeId_WmiOperatorEqualOrLessNode 8
  48. #define TypeId_WmiOperatorGreaterNode 9
  49. #define TypeId_WmiOperatorLessNode 10
  50. #define TypeId_WmiOperatorLikeNode 11
  51. #define TypeId_WmiOperatorNotLikeNode 12
  52. #define TypeId_WmiOperatorIsANode 13
  53. #define TypeId_WmiOperatorNotIsANode 14
  54. #define TypeId_WmiValueNode 15
  55. #define TypeId_WmiSignedIntegerNode 16
  56. #define TypeId_WmiUnsignedIntegerNode 17
  57. #define TypeId_WmiStringNode 18
  58. #define TypeId_WmiNullNode 19
  59. #define TypeId_WmiRangeNode 20
  60. #define TypeId_WmiUnsignedIntegerRangeNode 21
  61. #define TypeId_WmiSignedIntegerRangeNode 22
  62. #define TypeId_WmiStringRangeNode 23
  63. #define TypeId_WmiNullRangeNode 24
  64. /******************************************************************************
  65. *
  66. * Name:
  67. *
  68. *
  69. * Description:
  70. *
  71. *
  72. *****************************************************************************/
  73. class DllImportExport WmiOrNode : public WmiTreeNode
  74. {
  75. private:
  76. protected:
  77. public:
  78. WmiOrNode (
  79. WmiTreeNode *a_Left = NULL ,
  80. WmiTreeNode *a_Right = NULL ,
  81. WmiTreeNode *a_Parent = NULL
  82. ) : WmiTreeNode ( TypeId_WmiOrNode , NULL , a_Left , a_Right , a_Parent ) {}
  83. ~WmiOrNode () ;
  84. WmiTreeNode *Copy () ;
  85. void Print () ;
  86. } ;
  87. /******************************************************************************
  88. *
  89. * Name:
  90. *
  91. *
  92. * Description:
  93. *
  94. *
  95. *****************************************************************************/
  96. class DllImportExport WmiAndNode : public WmiTreeNode
  97. {
  98. private:
  99. protected:
  100. public:
  101. WmiAndNode (
  102. WmiTreeNode *a_Left = NULL ,
  103. WmiTreeNode *a_Right = NULL ,
  104. WmiTreeNode *a_Parent = NULL
  105. ) : WmiTreeNode ( TypeId_WmiAndNode , NULL , a_Left , a_Right , a_Parent ) {}
  106. ~WmiAndNode () ;
  107. WmiTreeNode *Copy () ;
  108. void Print () ;
  109. } ;
  110. /******************************************************************************
  111. *
  112. * Name:
  113. *
  114. *
  115. * Description:
  116. *
  117. *
  118. *****************************************************************************/
  119. class DllImportExport WmiNotNode : public WmiTreeNode
  120. {
  121. private:
  122. protected:
  123. public:
  124. WmiNotNode (
  125. WmiTreeNode *a_Node = NULL ,
  126. WmiTreeNode *a_Parent = NULL
  127. ) : WmiTreeNode ( TypeId_WmiNotNode , NULL , a_Node , NULL , a_Parent ) {}
  128. ~WmiNotNode () ;
  129. WmiTreeNode *Copy () ;
  130. void Print () ;
  131. } ;
  132. /******************************************************************************
  133. *
  134. * Name:
  135. *
  136. *
  137. * Description:
  138. *
  139. *
  140. *****************************************************************************/
  141. class DllImportExport WmiRangeNode ;
  142. /******************************************************************************
  143. *
  144. * Name:
  145. *
  146. *
  147. * Description:
  148. *
  149. *
  150. *****************************************************************************/
  151. class DllImportExport WmiOperatorNode : public WmiTreeNode
  152. {
  153. private:
  154. protected:
  155. public:
  156. WmiOperatorNode (
  157. TypeId_TreeNode a_Type ,
  158. WmiTreeNode *a_Node = NULL ,
  159. WmiTreeNode *a_Parent = NULL
  160. ) : WmiTreeNode ( a_Type , NULL , a_Node , NULL , a_Parent ) {}
  161. ~WmiOperatorNode () {} ;
  162. virtual WmiRangeNode *GetRange () = 0 ;
  163. } ;
  164. /******************************************************************************
  165. *
  166. * Name:
  167. *
  168. *
  169. * Description:
  170. *
  171. *
  172. *****************************************************************************/
  173. class DllImportExport WmiOperatorEqualNode : public WmiOperatorNode
  174. {
  175. private:
  176. protected:
  177. public:
  178. WmiOperatorEqualNode (
  179. WmiTreeNode *a_Node = NULL ,
  180. WmiTreeNode *a_Parent = NULL
  181. ) : WmiOperatorNode ( TypeId_WmiOperatorEqualNode , a_Node , a_Parent ) {}
  182. ~WmiOperatorEqualNode () ;
  183. WmiTreeNode *Copy () ;
  184. WmiRangeNode *GetRange () ;
  185. void Print () ;
  186. } ;
  187. /******************************************************************************
  188. *
  189. * Name:
  190. *
  191. *
  192. * Description:
  193. *
  194. *
  195. *****************************************************************************/
  196. class DllImportExport WmiOperatorNotEqualNode : public WmiOperatorNode
  197. {
  198. private:
  199. protected:
  200. public:
  201. WmiOperatorNotEqualNode (
  202. WmiTreeNode *a_Node = NULL ,
  203. WmiTreeNode *a_Parent = NULL
  204. ) : WmiOperatorNode ( TypeId_WmiOperatorNotEqualNode , a_Node , a_Parent ) {}
  205. ~WmiOperatorNotEqualNode () ;
  206. WmiTreeNode *Copy () ;
  207. WmiRangeNode *GetRange () { return NULL ; }
  208. void Print () ;
  209. } ;
  210. /******************************************************************************
  211. *
  212. * Name:
  213. *
  214. *
  215. * Description:
  216. *
  217. *
  218. *****************************************************************************/
  219. class DllImportExport WmiOperatorEqualOrGreaterNode : public WmiOperatorNode
  220. {
  221. private:
  222. protected:
  223. public:
  224. WmiOperatorEqualOrGreaterNode (
  225. WmiTreeNode *a_Node = NULL ,
  226. WmiTreeNode *a_Parent = NULL
  227. ) : WmiOperatorNode ( TypeId_WmiOperatorEqualOrGreaterNode , a_Node , a_Parent ) {}
  228. ~WmiOperatorEqualOrGreaterNode () ;
  229. WmiTreeNode *Copy () ;
  230. WmiRangeNode *GetRange () ;
  231. void Print () ;
  232. } ;
  233. /******************************************************************************
  234. *
  235. * Name:
  236. *
  237. *
  238. * Description:
  239. *
  240. *
  241. *****************************************************************************/
  242. class DllImportExport WmiOperatorEqualOrLessNode : public WmiOperatorNode
  243. {
  244. private:
  245. protected:
  246. public:
  247. WmiOperatorEqualOrLessNode (
  248. WmiTreeNode *a_Node = NULL ,
  249. WmiTreeNode *a_Parent = NULL
  250. ) : WmiOperatorNode ( TypeId_WmiOperatorEqualOrLessNode , a_Node , a_Parent ) {}
  251. ~WmiOperatorEqualOrLessNode () ;
  252. WmiTreeNode *Copy () ;
  253. WmiRangeNode *GetRange () ;
  254. void Print () ;
  255. } ;
  256. /******************************************************************************
  257. *
  258. * Name:
  259. *
  260. *
  261. * Description:
  262. *
  263. *
  264. *****************************************************************************/
  265. class DllImportExport WmiOperatorGreaterNode : public WmiOperatorNode
  266. {
  267. private:
  268. protected:
  269. public:
  270. WmiOperatorGreaterNode (
  271. WmiTreeNode *a_Node = NULL ,
  272. WmiTreeNode *a_Parent = NULL
  273. ) : WmiOperatorNode ( TypeId_WmiOperatorGreaterNode , a_Node , a_Parent ) {}
  274. ~WmiOperatorGreaterNode () ;
  275. WmiTreeNode *Copy () ;
  276. WmiRangeNode *GetRange () ;
  277. void Print () ;
  278. } ;
  279. /******************************************************************************
  280. *
  281. * Name:
  282. *
  283. *
  284. * Description:
  285. *
  286. *
  287. *****************************************************************************/
  288. class DllImportExport WmiOperatorLessNode : public WmiOperatorNode
  289. {
  290. private:
  291. protected:
  292. public:
  293. WmiOperatorLessNode (
  294. WmiTreeNode *a_Node = NULL ,
  295. WmiTreeNode *a_Parent = NULL
  296. ) : WmiOperatorNode ( TypeId_WmiOperatorLessNode , a_Node , a_Parent ) {}
  297. ~WmiOperatorLessNode () ;
  298. WmiTreeNode *Copy () ;
  299. WmiRangeNode *GetRange () ;
  300. void Print () ;
  301. } ;
  302. /******************************************************************************
  303. *
  304. * Name:
  305. *
  306. *
  307. * Description:
  308. *
  309. *
  310. *****************************************************************************/
  311. class DllImportExport WmiOperatorLikeNode : public WmiOperatorNode
  312. {
  313. private:
  314. protected:
  315. public:
  316. WmiOperatorLikeNode (
  317. WmiTreeNode *a_Node = NULL ,
  318. WmiTreeNode *a_Parent = NULL
  319. ) : WmiOperatorNode ( TypeId_WmiOperatorLikeNode , a_Node , a_Parent ) {}
  320. ~WmiOperatorLikeNode () ;
  321. WmiTreeNode *Copy () ;
  322. WmiRangeNode *GetRange () ;
  323. void Print () ;
  324. } ;
  325. /******************************************************************************
  326. *
  327. * Name:
  328. *
  329. *
  330. * Description:
  331. *
  332. *
  333. *****************************************************************************/
  334. class DllImportExport WmiOperatorNotLikeNode : public WmiOperatorNode
  335. {
  336. private:
  337. protected:
  338. public:
  339. WmiOperatorNotLikeNode (
  340. WmiTreeNode *a_Node = NULL ,
  341. WmiTreeNode *a_Parent = NULL
  342. ) : WmiOperatorNode ( TypeId_WmiOperatorNotLikeNode , a_Node , a_Parent ) {}
  343. ~WmiOperatorNotLikeNode () ;
  344. WmiTreeNode *Copy () ;
  345. WmiRangeNode *GetRange () ;
  346. void Print () ;
  347. } ;
  348. /******************************************************************************
  349. *
  350. * Name:
  351. *
  352. *
  353. * Description:
  354. *
  355. *
  356. *****************************************************************************/
  357. class DllImportExport WmiOperatorIsANode : public WmiOperatorNode
  358. {
  359. private:
  360. protected:
  361. public:
  362. WmiOperatorIsANode (
  363. WmiTreeNode *a_Node = NULL ,
  364. WmiTreeNode *a_Parent = NULL
  365. ) : WmiOperatorNode ( TypeId_WmiOperatorIsANode , a_Node , a_Parent ) {}
  366. ~WmiOperatorIsANode () ;
  367. WmiTreeNode *Copy () ;
  368. WmiRangeNode *GetRange () ;
  369. void Print () ;
  370. } ;
  371. /******************************************************************************
  372. *
  373. * Name:
  374. *
  375. *
  376. * Description:
  377. *
  378. *
  379. *****************************************************************************/
  380. class DllImportExport WmiOperatorNotIsANode : public WmiOperatorNode
  381. {
  382. private:
  383. protected:
  384. public:
  385. WmiOperatorNotIsANode (
  386. WmiTreeNode *a_Node = NULL ,
  387. WmiTreeNode *a_Parent = NULL
  388. ) : WmiOperatorNode ( TypeId_WmiOperatorNotIsANode , a_Node , a_Parent ) {}
  389. ~WmiOperatorNotIsANode () ;
  390. WmiTreeNode *Copy () ;
  391. WmiRangeNode *GetRange () ;
  392. void Print () ;
  393. } ;
  394. /******************************************************************************
  395. *
  396. * Name:
  397. *
  398. *
  399. * Description:
  400. *
  401. *
  402. *****************************************************************************/
  403. class DllImportExport WmiValueNode : public WmiTreeNode
  404. {
  405. public:
  406. enum WmiValueFunction
  407. {
  408. Function_None = 0 ,
  409. Function_Upper = 1 ,
  410. Function_Lower = 2
  411. } ;
  412. private:
  413. protected:
  414. BSTR m_PropertyName ;
  415. ULONG m_Index ;
  416. WmiValueFunction m_PropertyFunction ;
  417. WmiValueFunction m_ConstantFunction ;
  418. public:
  419. WmiValueNode (
  420. TypeId_TreeNode a_Type ,
  421. BSTR a_PropertyName ,
  422. WmiValueFunction a_PropertyFunction ,
  423. WmiValueFunction a_ConstantFunction ,
  424. ULONG a_Index ,
  425. WmiTreeNode *a_Parent = NULL
  426. ) : WmiTreeNode ( a_Type , NULL , NULL , NULL , a_Parent ) ,
  427. m_PropertyFunction ( a_PropertyFunction ) ,
  428. m_ConstantFunction ( a_ConstantFunction ) ,
  429. m_Index ( a_Index )
  430. {
  431. if ( a_PropertyName )
  432. {
  433. m_PropertyName = SysAllocString ( a_PropertyName ) ;
  434. if ( m_PropertyName == NULL )
  435. {
  436. throw Heap_Exception(Heap_Exception::HEAP_ERROR::E_ALLOCATION_ERROR);
  437. }
  438. }
  439. else
  440. {
  441. m_PropertyName = NULL ;
  442. }
  443. }
  444. ~WmiValueNode ()
  445. {
  446. if ( m_PropertyName )
  447. SysFreeString ( m_PropertyName ) ;
  448. }
  449. BSTR GetPropertyName ()
  450. {
  451. return m_PropertyName ;
  452. }
  453. ULONG GetIndex () { return m_Index ; }
  454. WmiValueNode :: WmiValueFunction GetPropertyFunction ()
  455. {
  456. return m_PropertyFunction ;
  457. }
  458. WmiValueNode :: WmiValueFunction GetConstantFunction ()
  459. {
  460. return m_ConstantFunction ;
  461. }
  462. LONG ComparePropertyName ( WmiValueNode &a_ValueNode )
  463. {
  464. if ( m_Index < a_ValueNode.m_Index )
  465. {
  466. return -1 ;
  467. }
  468. else if ( m_Index > a_ValueNode.m_Index )
  469. {
  470. return 1 ;
  471. }
  472. else
  473. {
  474. return _wcsicmp ( m_PropertyName , a_ValueNode.m_PropertyName ) ;
  475. }
  476. }
  477. } ;
  478. /******************************************************************************
  479. *
  480. * Name:
  481. *
  482. *
  483. * Description:
  484. *
  485. *
  486. *****************************************************************************/
  487. class DllImportExport WmiSignedIntegerNode : public WmiValueNode
  488. {
  489. private:
  490. protected:
  491. LONG m_Integer ;
  492. public:
  493. WmiSignedIntegerNode (
  494. BSTR a_PropertyName ,
  495. LONG a_Integer ,
  496. ULONG a_Index ,
  497. WmiTreeNode *a_Parent = NULL
  498. ) : WmiValueNode (
  499. TypeId_WmiSignedIntegerNode ,
  500. a_PropertyName ,
  501. Function_None ,
  502. Function_None ,
  503. a_Index ,
  504. a_Parent
  505. ) , m_Integer ( a_Integer )
  506. {
  507. }
  508. WmiTreeNode *Copy () ;
  509. BOOL LexicographicallyBefore ( LONG &a_Integer )
  510. {
  511. if ( m_Integer == 0x80000000 )
  512. {
  513. return FALSE ;
  514. }
  515. else
  516. {
  517. a_Integer = m_Integer - 1 ;
  518. return TRUE ;
  519. }
  520. }
  521. BOOL LexicographicallyAfter ( LONG &a_Integer )
  522. {
  523. if ( m_Integer == 0x7FFFFFFF )
  524. {
  525. return FALSE ;
  526. }
  527. else
  528. {
  529. a_Integer = m_Integer + 1 ;
  530. return TRUE ;
  531. }
  532. }
  533. LONG GetValue ()
  534. {
  535. return m_Integer ;
  536. }
  537. void Print () ;
  538. } ;
  539. /******************************************************************************
  540. *
  541. * Name:
  542. *
  543. *
  544. * Description:
  545. *
  546. *
  547. *****************************************************************************/
  548. class DllImportExport WmiUnsignedIntegerNode : public WmiValueNode
  549. {
  550. private:
  551. protected:
  552. ULONG m_Integer ;
  553. public:
  554. WmiUnsignedIntegerNode (
  555. BSTR a_PropertyName ,
  556. ULONG a_Integer ,
  557. ULONG a_Index ,
  558. WmiTreeNode *a_Parent = NULL
  559. ) : WmiValueNode (
  560. TypeId_WmiUnsignedIntegerNode ,
  561. a_PropertyName ,
  562. Function_None ,
  563. Function_None ,
  564. a_Index ,
  565. a_Parent
  566. ) , m_Integer ( a_Integer )
  567. {
  568. }
  569. WmiTreeNode *Copy () ;
  570. BOOL LexicographicallyBefore ( ULONG &a_Integer )
  571. {
  572. if ( m_Integer == 0 )
  573. {
  574. return FALSE ;
  575. }
  576. else
  577. {
  578. a_Integer = m_Integer - 1 ;
  579. return TRUE ;
  580. }
  581. }
  582. BOOL LexicographicallyAfter ( ULONG &a_Integer )
  583. {
  584. if ( m_Integer == 0xFFFFFFFF )
  585. {
  586. return FALSE ;
  587. }
  588. else
  589. {
  590. a_Integer = m_Integer + 1 ;
  591. return TRUE ;
  592. }
  593. }
  594. ULONG GetValue ()
  595. {
  596. return m_Integer ;
  597. }
  598. void Print () ;
  599. } ;
  600. /******************************************************************************
  601. *
  602. * Name:
  603. *
  604. *
  605. * Description:
  606. *
  607. *
  608. *****************************************************************************/
  609. class DllImportExport WmiStringNode : public WmiValueNode
  610. {
  611. private:
  612. protected:
  613. BSTR m_String ;
  614. public:
  615. WmiStringNode (
  616. BSTR a_PropertyName ,
  617. BSTR a_String ,
  618. WmiValueNode :: WmiValueFunction a_PropertyFunction ,
  619. WmiValueNode :: WmiValueFunction a_ConstantFunction ,
  620. ULONG a_Index ,
  621. WmiTreeNode *a_Parent = NULL
  622. ) ;
  623. ~WmiStringNode () ;
  624. WmiTreeNode *Copy () ;
  625. BOOL LexicographicallyBefore ( BSTR &a_String ) ;
  626. BOOL LexicographicallyAfter ( BSTR &a_String ) ;
  627. BSTR GetValue ()
  628. {
  629. return m_String ;
  630. }
  631. void Print () ;
  632. } ;
  633. /******************************************************************************
  634. *
  635. * Name:
  636. *
  637. *
  638. * Description:
  639. *
  640. *
  641. *****************************************************************************/
  642. class DllImportExport WmiNullNode : public WmiValueNode
  643. {
  644. private:
  645. protected:
  646. public:
  647. WmiNullNode (
  648. BSTR a_PropertyName ,
  649. ULONG a_Index ,
  650. WmiTreeNode *a_Parent = NULL
  651. ) : WmiValueNode (
  652. TypeId_WmiNullNode ,
  653. a_PropertyName ,
  654. Function_None ,
  655. Function_None ,
  656. a_Index ,
  657. a_Parent
  658. )
  659. {
  660. }
  661. WmiTreeNode *Copy () ;
  662. void Print () ;
  663. } ;
  664. /******************************************************************************
  665. *
  666. * Name:
  667. *
  668. *
  669. * Description:
  670. *
  671. *
  672. *****************************************************************************/
  673. class DllImportExport WmiRangeNode : public WmiTreeNode
  674. {
  675. private:
  676. protected:
  677. BSTR m_PropertyName ;
  678. ULONG m_Index ;
  679. BOOL m_InfiniteLowerBound ;
  680. BOOL m_InfiniteUpperBound ;
  681. BOOL m_LowerBoundClosed;
  682. BOOL m_UpperBoundClosed;
  683. public:
  684. LONG ComparePropertyName ( WmiRangeNode &a_RangeNode )
  685. {
  686. if ( m_Index < a_RangeNode.m_Index )
  687. {
  688. return -1 ;
  689. }
  690. else if ( m_Index > a_RangeNode.m_Index )
  691. {
  692. return 1 ;
  693. }
  694. else
  695. {
  696. return _wcsicmp ( m_PropertyName , a_RangeNode.m_PropertyName ) ;
  697. }
  698. }
  699. public:
  700. WmiRangeNode (
  701. TypeId_TreeNode a_Type ,
  702. BSTR a_PropertyName ,
  703. ULONG a_Index ,
  704. BOOL a_InfiniteLowerBound ,
  705. BOOL a_InfiniteUpperBound ,
  706. BOOL a_LowerBoundClosed ,
  707. BOOL a_UpperBoundClosed ,
  708. WmiTreeNode *a_NextNode = NULL ,
  709. WmiTreeNode *a_Parent = NULL
  710. ) : WmiTreeNode ( a_Type , NULL , NULL , a_NextNode , a_Parent ),
  711. m_InfiniteLowerBound ( a_InfiniteLowerBound ) ,
  712. m_InfiniteUpperBound ( a_InfiniteUpperBound ) ,
  713. m_LowerBoundClosed ( a_LowerBoundClosed ) ,
  714. m_UpperBoundClosed ( a_UpperBoundClosed ) ,
  715. m_Index ( a_Index )
  716. {
  717. if ( a_PropertyName )
  718. {
  719. m_PropertyName = SysAllocString ( a_PropertyName ) ;
  720. if ( NULL == m_PropertyName )
  721. {
  722. throw Heap_Exception(Heap_Exception::HEAP_ERROR::E_ALLOCATION_ERROR);
  723. }
  724. }
  725. else
  726. {
  727. m_PropertyName = NULL ;
  728. }
  729. } ;
  730. ~WmiRangeNode ()
  731. {
  732. if ( m_PropertyName )
  733. {
  734. SysFreeString ( m_PropertyName ) ;
  735. }
  736. } ;
  737. BSTR GetPropertyName ()
  738. {
  739. return m_PropertyName ;
  740. }
  741. ULONG GetIndex () { return m_Index ; }
  742. BOOL InfiniteLowerBound () { return m_InfiniteLowerBound ; }
  743. BOOL InfiniteUpperBound () { return m_InfiniteUpperBound ; }
  744. BOOL ClosedLowerBound () { return m_LowerBoundClosed ; }
  745. BOOL ClosedUpperBound () { return m_UpperBoundClosed ; }
  746. } ;
  747. /******************************************************************************
  748. *
  749. * Name:
  750. *
  751. *
  752. * Description:
  753. *
  754. *
  755. *****************************************************************************/
  756. class DllImportExport WmiUnsignedIntegerRangeNode : public WmiRangeNode
  757. {
  758. private:
  759. protected:
  760. ULONG m_LowerBound ;
  761. ULONG m_UpperBound ;
  762. public:
  763. WmiTreeNode *Copy () ;
  764. WmiTriState GetIntersectingRange (
  765. WmiUnsignedIntegerRangeNode &a_Range ,
  766. WmiUnsignedIntegerRangeNode *&a_Intersection
  767. ) ;
  768. WmiTriState GetOverlappingRange (
  769. WmiUnsignedIntegerRangeNode &a_Range ,
  770. WmiUnsignedIntegerRangeNode *&a_Intersection
  771. ) ;
  772. public:
  773. WmiUnsignedIntegerRangeNode (
  774. BSTR a_PropertyName ,
  775. ULONG a_Index ,
  776. BOOL a_InfiniteLowerBound ,
  777. BOOL a_InfiniteUpperBound ,
  778. BOOL a_LowerBoundClosed ,
  779. BOOL a_UpperBoundClosed ,
  780. ULONG a_LowerBound ,
  781. ULONG a_UpperBound ,
  782. WmiTreeNode *a_NextNode = NULL ,
  783. WmiTreeNode *a_Parent = NULL
  784. ) : WmiRangeNode (
  785. TypeId_WmiUnsignedIntegerRangeNode ,
  786. a_PropertyName ,
  787. a_Index ,
  788. a_InfiniteLowerBound ,
  789. a_InfiniteUpperBound ,
  790. a_LowerBoundClosed ,
  791. a_UpperBoundClosed ,
  792. a_NextNode ,
  793. a_Parent
  794. ) ,
  795. m_LowerBound ( a_LowerBound ) ,
  796. m_UpperBound ( a_UpperBound )
  797. {
  798. }
  799. ULONG LowerBound () { return m_LowerBound ; }
  800. ULONG UpperBound () { return m_UpperBound ; }
  801. void Print () ;
  802. } ;
  803. /******************************************************************************
  804. *
  805. * Name:
  806. *
  807. *
  808. * Description:
  809. *
  810. *
  811. *****************************************************************************/
  812. class DllImportExport WmiSignedIntegerRangeNode : public WmiRangeNode
  813. {
  814. private:
  815. protected:
  816. LONG m_LowerBound ;
  817. LONG m_UpperBound ;
  818. public:
  819. WmiTreeNode *Copy () ;
  820. WmiTriState GetIntersectingRange (
  821. WmiSignedIntegerRangeNode &a_Range ,
  822. WmiSignedIntegerRangeNode *&a_Intersection
  823. ) ;
  824. WmiTriState GetOverlappingRange (
  825. WmiSignedIntegerRangeNode &a_Range ,
  826. WmiSignedIntegerRangeNode *&a_Intersection
  827. ) ;
  828. public:
  829. WmiSignedIntegerRangeNode (
  830. BSTR a_PropertyName ,
  831. ULONG a_Index ,
  832. BOOL a_InfiniteLowerBound ,
  833. BOOL a_InfiniteUpperBound ,
  834. BOOL a_LowerBoundClosed ,
  835. BOOL a_UpperBoundClosed ,
  836. LONG a_LowerBound ,
  837. LONG a_UpperBound ,
  838. WmiTreeNode *a_NextNode = NULL ,
  839. WmiTreeNode *a_Parent = NULL
  840. ) : WmiRangeNode (
  841. TypeId_WmiSignedIntegerRangeNode ,
  842. a_PropertyName ,
  843. a_Index ,
  844. a_InfiniteLowerBound ,
  845. a_InfiniteUpperBound ,
  846. a_LowerBoundClosed ,
  847. a_UpperBoundClosed ,
  848. a_NextNode ,
  849. a_Parent
  850. ) ,
  851. m_LowerBound ( a_LowerBound ) ,
  852. m_UpperBound ( a_UpperBound )
  853. {
  854. }
  855. LONG LowerBound () { return m_LowerBound ; }
  856. LONG UpperBound () { return m_UpperBound ; }
  857. void Print () ;
  858. } ;
  859. /******************************************************************************
  860. *
  861. * Name:
  862. *
  863. *
  864. * Description:
  865. *
  866. *
  867. *****************************************************************************/
  868. class DllImportExport WmiStringRangeNode : public WmiRangeNode
  869. {
  870. private:
  871. protected:
  872. BSTR m_LowerBound ;
  873. BSTR m_UpperBound ;
  874. public:
  875. WmiTreeNode *Copy () ;
  876. WmiTriState GetIntersectingRange (
  877. WmiStringRangeNode &a_Range ,
  878. WmiStringRangeNode *&a_Intersection
  879. ) ;
  880. WmiTriState GetOverlappingRange (
  881. WmiStringRangeNode &a_Range ,
  882. WmiStringRangeNode *&a_Intersection
  883. ) ;
  884. public:
  885. WmiStringRangeNode (
  886. BSTR a_PropertyName ,
  887. ULONG a_Index ,
  888. BOOL a_InfiniteLowerBound ,
  889. BOOL a_InfiniteUpperBound ,
  890. BOOL a_LowerBoundClosed ,
  891. BOOL a_UpperBoundClosed ,
  892. BSTR a_LowerBound ,
  893. BSTR a_UpperBound ,
  894. WmiTreeNode *a_NextNode = NULL ,
  895. WmiTreeNode *a_Parent = NULL
  896. ) : WmiRangeNode (
  897. TypeId_WmiStringRangeNode ,
  898. a_PropertyName ,
  899. a_Index ,
  900. a_InfiniteLowerBound ,
  901. a_InfiniteUpperBound ,
  902. a_LowerBoundClosed ,
  903. a_UpperBoundClosed ,
  904. a_NextNode ,
  905. a_Parent
  906. )
  907. {
  908. if ( a_LowerBound )
  909. {
  910. m_LowerBound = SysAllocString ( a_LowerBound ) ;
  911. if ( NULL == m_LowerBound )
  912. {
  913. throw Heap_Exception(Heap_Exception::HEAP_ERROR::E_ALLOCATION_ERROR);
  914. }
  915. }
  916. else
  917. {
  918. m_LowerBound = NULL ;
  919. }
  920. if ( a_UpperBound )
  921. {
  922. m_UpperBound = SysAllocString ( a_UpperBound ) ;
  923. if ( NULL == m_UpperBound )
  924. {
  925. throw Heap_Exception(Heap_Exception::HEAP_ERROR::E_ALLOCATION_ERROR);
  926. }
  927. }
  928. else
  929. {
  930. m_UpperBound = NULL ;
  931. }
  932. }
  933. ~WmiStringRangeNode ()
  934. {
  935. if ( m_LowerBound )
  936. {
  937. SysFreeString ( m_LowerBound ) ;
  938. }
  939. if ( m_UpperBound )
  940. {
  941. SysFreeString ( m_UpperBound ) ;
  942. }
  943. } ;
  944. BSTR LowerBound () { return m_LowerBound ; }
  945. BSTR UpperBound () { return m_UpperBound ; }
  946. void Print () ;
  947. } ;
  948. /******************************************************************************
  949. *
  950. * Name:
  951. *
  952. *
  953. * Description:
  954. *
  955. *
  956. *****************************************************************************/
  957. class DllImportExport WmiNullRangeNode : public WmiRangeNode
  958. {
  959. private:
  960. protected:
  961. public:
  962. WmiNullRangeNode (
  963. BSTR a_PropertyName ,
  964. ULONG a_Index ,
  965. WmiTreeNode *a_NextNode = NULL ,
  966. WmiTreeNode *a_Parent = NULL
  967. ) : WmiRangeNode (
  968. TypeId_WmiNullRangeNode ,
  969. a_PropertyName ,
  970. a_Index ,
  971. TRUE ,
  972. TRUE ,
  973. FALSE ,
  974. FALSE ,
  975. a_NextNode ,
  976. a_Parent
  977. )
  978. {
  979. }
  980. ~WmiNullRangeNode ()
  981. {
  982. } ;
  983. WmiTreeNode *Copy () ;
  984. void Print () ;
  985. } ;
  986. /******************************************************************************
  987. *
  988. * Name:
  989. *
  990. *
  991. * Description:
  992. *
  993. *
  994. *****************************************************************************/
  995. class DllImportExport Conjunctions
  996. {
  997. private:
  998. protected:
  999. /*
  1000. * Range values for the set of properties in a disjunction.
  1001. * Array index is ordered in property order.
  1002. */
  1003. ULONG m_RangeContainerCount ;
  1004. WmiRangeNode **m_RangeContainer ;
  1005. public:
  1006. Conjunctions (
  1007. ULONG a_RangeContainerCount
  1008. ) : m_RangeContainerCount ( a_RangeContainerCount ) ,
  1009. m_RangeContainer ( NULL )
  1010. {
  1011. }
  1012. ~Conjunctions ()
  1013. {
  1014. if ( m_RangeContainer )
  1015. {
  1016. for ( ULONG t_Index = 0 ; t_Index < m_RangeContainerCount ; t_Index ++ )
  1017. {
  1018. delete m_RangeContainer [ t_Index ] ;
  1019. }
  1020. delete [] m_RangeContainer ;
  1021. }
  1022. } ;
  1023. WmiTriState Initialize ()
  1024. {
  1025. WmiTriState t_Status = State_True ;
  1026. m_RangeContainer = new WmiRangeNode * [ m_RangeContainerCount ] ;
  1027. if ( m_RangeContainer )
  1028. {
  1029. for ( ULONG t_Index = 0 ; t_Index < m_RangeContainerCount ; t_Index ++ )
  1030. {
  1031. m_RangeContainer [ t_Index ] = NULL ;
  1032. }
  1033. }
  1034. else
  1035. {
  1036. t_Status = State_Error ;
  1037. }
  1038. return t_Status ;
  1039. }
  1040. ULONG GetRangeCount ()
  1041. {
  1042. return m_RangeContainerCount ;
  1043. }
  1044. WmiRangeNode *GetRange ( ULONG a_Index )
  1045. {
  1046. if ( m_RangeContainerCount > a_Index )
  1047. {
  1048. return m_RangeContainer [ a_Index ] ;
  1049. }
  1050. else
  1051. {
  1052. return NULL ;
  1053. }
  1054. }
  1055. void SetRange ( ULONG a_Index , WmiRangeNode *a_Range )
  1056. {
  1057. if ( m_RangeContainerCount > a_Index )
  1058. {
  1059. if ( m_RangeContainer [ a_Index ] )
  1060. {
  1061. delete m_RangeContainer [ a_Index ] ;
  1062. }
  1063. m_RangeContainer [ a_Index ] = a_Range ;
  1064. }
  1065. }
  1066. } ;
  1067. /******************************************************************************
  1068. *
  1069. * Name:
  1070. *
  1071. *
  1072. * Description:
  1073. *
  1074. *
  1075. *****************************************************************************/
  1076. class DllImportExport Disjunctions
  1077. {
  1078. private:
  1079. protected:
  1080. /*
  1081. * Range values for the set of properties in a disjunction.
  1082. * Array index is ordered in property order.
  1083. */
  1084. ULONG m_ConjunctionCount ;
  1085. ULONG m_DisjunctionCount ;
  1086. Conjunctions **m_Disjunction ;
  1087. public:
  1088. Disjunctions (
  1089. ULONG a_DisjunctionCount ,
  1090. ULONG a_ConjunctionCount
  1091. ) : m_DisjunctionCount ( a_DisjunctionCount ) ,
  1092. m_ConjunctionCount ( a_ConjunctionCount ) ,
  1093. m_Disjunction ( NULL )
  1094. {
  1095. }
  1096. WmiTriState Initialize ()
  1097. {
  1098. WmiTriState t_Status = State_True ;
  1099. m_Disjunction = new Conjunctions * [ m_DisjunctionCount ] ;
  1100. if ( m_Disjunction )
  1101. {
  1102. for ( ULONG t_Index = 0 ; t_Index < m_DisjunctionCount ; t_Index ++ )
  1103. {
  1104. m_Disjunction [ t_Index ] = NULL ;
  1105. }
  1106. for ( t_Index = 0 ; t_Index < m_DisjunctionCount ; t_Index ++ )
  1107. {
  1108. Conjunctions *t_Disjunction = new Conjunctions ( m_ConjunctionCount ) ;
  1109. if ( t_Disjunction )
  1110. {
  1111. t_Status = t_Disjunction->Initialize () ;
  1112. if ( t_Status != State_True )
  1113. {
  1114. break ;
  1115. }
  1116. }
  1117. else
  1118. {
  1119. t_Status = State_Error ;
  1120. break ;
  1121. }
  1122. m_Disjunction [ t_Index ] = t_Disjunction ;
  1123. }
  1124. }
  1125. else
  1126. {
  1127. t_Status = State_Error ;
  1128. }
  1129. return t_Status ;
  1130. }
  1131. ~Disjunctions ()
  1132. {
  1133. if ( m_Disjunction )
  1134. {
  1135. for ( ULONG t_Index = 0 ; t_Index < m_DisjunctionCount ; t_Index ++ )
  1136. {
  1137. Conjunctions *t_Disjunction = m_Disjunction [ t_Index ] ;
  1138. delete t_Disjunction ;
  1139. }
  1140. delete [] m_Disjunction ;
  1141. }
  1142. } ;
  1143. ULONG GetDisjunctionCount ()
  1144. {
  1145. return m_DisjunctionCount ;
  1146. }
  1147. ULONG GetConjunctionCount ()
  1148. {
  1149. return m_ConjunctionCount ;
  1150. }
  1151. Conjunctions *GetDisjunction ( ULONG a_Index )
  1152. {
  1153. if ( m_DisjunctionCount > a_Index )
  1154. {
  1155. return m_Disjunction [ a_Index ] ;
  1156. }
  1157. else
  1158. {
  1159. return NULL ;
  1160. }
  1161. }
  1162. } ;
  1163. /******************************************************************************
  1164. *
  1165. * Name:
  1166. *
  1167. *
  1168. * Description:
  1169. *
  1170. *
  1171. *****************************************************************************/
  1172. class DllImportExport PartitionSet
  1173. {
  1174. private:
  1175. protected:
  1176. /*
  1177. * Null for top level
  1178. */
  1179. ULONG m_KeyIndex ;
  1180. WmiRangeNode *m_Range ;
  1181. /*
  1182. * Number of non overlapping partitions, zero when all keys have been partitioned
  1183. */
  1184. ULONG m_NumberOfNonOverlappingPartitions ;
  1185. PartitionSet **m_NonOverlappingPartitions ;
  1186. public:
  1187. PartitionSet () : m_Range ( NULL ) ,
  1188. m_KeyIndex ( 0 ) ,
  1189. m_NumberOfNonOverlappingPartitions ( 0 ) ,
  1190. m_NonOverlappingPartitions ( NULL )
  1191. {
  1192. }
  1193. virtual ~PartitionSet ()
  1194. {
  1195. delete m_Range ;
  1196. if ( m_NonOverlappingPartitions )
  1197. {
  1198. for ( ULONG t_Index = 0 ; t_Index < m_NumberOfNonOverlappingPartitions ; t_Index ++ )
  1199. {
  1200. delete m_NonOverlappingPartitions [ t_Index ] ;
  1201. }
  1202. delete [] m_NonOverlappingPartitions ;
  1203. }
  1204. }
  1205. public:
  1206. WmiTriState Initialize ( ULONG a_Count )
  1207. {
  1208. WmiTriState t_Status = State_True ;
  1209. m_NumberOfNonOverlappingPartitions = a_Count ;
  1210. m_NonOverlappingPartitions = new PartitionSet * [ a_Count ] ;
  1211. if ( m_NonOverlappingPartitions )
  1212. {
  1213. for ( ULONG t_Index = 0 ; t_Index < a_Count ; t_Index ++ )
  1214. {
  1215. m_NonOverlappingPartitions [ t_Index ] = NULL ;
  1216. }
  1217. }
  1218. else
  1219. {
  1220. t_Status = State_Error ;
  1221. }
  1222. return t_Status ;
  1223. }
  1224. void SetPartition ( ULONG a_Index , PartitionSet *a_Partition )
  1225. {
  1226. if ( a_Index < m_NumberOfNonOverlappingPartitions )
  1227. {
  1228. m_NonOverlappingPartitions [ a_Index ] = a_Partition ;
  1229. }
  1230. }
  1231. public:
  1232. ULONG GetKeyIndex () { return m_KeyIndex ; }
  1233. void SetKeyIndex ( ULONG a_KeyIndex ) { m_KeyIndex = a_KeyIndex ; }
  1234. BOOL Root () { return m_Range == NULL ; }
  1235. BOOL Leaf () { return m_NonOverlappingPartitions == NULL ; }
  1236. void SetRange ( WmiRangeNode *a_Range ) { m_Range = a_Range ; }
  1237. WmiRangeNode *GetRange () { return m_Range ; }
  1238. ULONG GetPartitionCount () { return m_NumberOfNonOverlappingPartitions ; }
  1239. PartitionSet *GetPartition ( ULONG a_Index )
  1240. {
  1241. if ( a_Index < m_NumberOfNonOverlappingPartitions )
  1242. {
  1243. return m_NonOverlappingPartitions [ a_Index ] ;
  1244. }
  1245. else
  1246. {
  1247. return NULL ;
  1248. }
  1249. }
  1250. } ;
  1251. /******************************************************************************
  1252. *
  1253. * Name:
  1254. *
  1255. *
  1256. * Description:
  1257. *
  1258. *
  1259. *****************************************************************************/
  1260. class DllImportExport QueryPreprocessor
  1261. {
  1262. public:
  1263. enum QuadState {
  1264. State_True ,
  1265. State_False ,
  1266. State_ReEvaluate ,
  1267. State_Undefined ,
  1268. State_Error
  1269. } ;
  1270. private:
  1271. protected:
  1272. BOOL RecursiveEvaluate (
  1273. void *a_Context ,
  1274. SQL_LEVEL_1_RPN_EXPRESSION & a_Expression ,
  1275. WmiTreeNode *a_Parent ,
  1276. WmiTreeNode **a_Node ,
  1277. int &a_Index
  1278. ) ;
  1279. void TransformAndOrExpression (
  1280. WmiTreeNode *&a_Node ,
  1281. WmiTreeNode *a_AndChild ,
  1282. WmiTreeNode *a_OrChild
  1283. ) ;
  1284. void TransformNotNotExpression (
  1285. WmiTreeNode *&a_Node ,
  1286. WmiTreeNode *a_Child
  1287. ) ;
  1288. void TransformNotAndExpression (
  1289. WmiTreeNode *&a_Node ,
  1290. WmiTreeNode *a_Child
  1291. ) ;
  1292. void TransformNotOperatorEqualExpression (
  1293. WmiTreeNode *&a_Node ,
  1294. WmiTreeNode *a_Child
  1295. ) ;
  1296. void TransformNotOperatorNotEqualExpression (
  1297. WmiTreeNode *&a_Node ,
  1298. WmiTreeNode *a_Child
  1299. ) ;
  1300. void TransformNotOperatorEqualOrGreaterExpression (
  1301. WmiTreeNode *&a_Node ,
  1302. WmiTreeNode *a_Child
  1303. ) ;
  1304. void TransformNotOperatorEqualOrLessExpression (
  1305. WmiTreeNode *&a_Node ,
  1306. WmiTreeNode *a_Child
  1307. ) ;
  1308. void TransformNotOperatorGreaterExpression (
  1309. WmiTreeNode *&a_Node ,
  1310. WmiTreeNode *a_Child
  1311. ) ;
  1312. void TransformNotOperatorLessExpression (
  1313. WmiTreeNode *&a_Node ,
  1314. WmiTreeNode *a_Child
  1315. ) ;
  1316. void TransformNotOperatorLikeExpression (
  1317. WmiTreeNode *&a_Node ,
  1318. WmiTreeNode *a_Child
  1319. ) ;
  1320. void TransformNotOperatorNotLikeExpression (
  1321. WmiTreeNode *&a_Node ,
  1322. WmiTreeNode *a_Child
  1323. ) ;
  1324. void TransformNotOperatorIsAExpression (
  1325. WmiTreeNode *&a_Node ,
  1326. WmiTreeNode *a_Child
  1327. ) ;
  1328. void TransformNotOperatorNotIsAExpression (
  1329. WmiTreeNode *&a_Node ,
  1330. WmiTreeNode *a_Child
  1331. ) ;
  1332. void TransformNotOrExpression (
  1333. WmiTreeNode *&a_Node ,
  1334. WmiTreeNode *a_Child
  1335. ) ;
  1336. void TransformNotEqualExpression (
  1337. WmiTreeNode *&a_Node ,
  1338. WmiTreeNode *a_Child
  1339. ) ;
  1340. void TransformAndTrueEvaluation (
  1341. WmiTreeNode *&a_Node ,
  1342. WmiTreeNode *a_Child
  1343. ) ;
  1344. void TransformOrFalseEvaluation (
  1345. WmiTreeNode *&a_Node ,
  1346. WmiTreeNode *a_Child
  1347. ) ;
  1348. void TransformOperatorToRange (
  1349. WmiTreeNode *&a_Node
  1350. ) ;
  1351. void TransformIntersectingRange (
  1352. WmiTreeNode *&a_Node ,
  1353. WmiTreeNode *a_Compare ,
  1354. WmiTreeNode *a_Intersection
  1355. ) ;
  1356. void TransformNonIntersectingRange (
  1357. WmiTreeNode *&a_Node ,
  1358. WmiTreeNode *a_Compare
  1359. ) ;
  1360. WmiTriState EvaluateNotEqualExpression ( WmiTreeNode *&a_Node ) ;
  1361. WmiTriState EvaluateNotExpression ( WmiTreeNode *&a_Node ) ;
  1362. WmiTriState EvaluateAndExpression ( WmiTreeNode *&a_Node ) ;
  1363. WmiTriState EvaluateOrExpression ( WmiTreeNode *&a_Node ) ;
  1364. QuadState RecursiveDisjunctiveNormalForm ( WmiTreeNode *&a_Node ) ;
  1365. QuadState RecursiveRemoveInvariants ( void *a_Context , WmiTreeNode *&a_Root ) ;
  1366. WmiTriState RecursiveInsertNode ( WmiTreeNode *&a_Root , WmiTreeNode *&a_Node ) ;
  1367. WmiTriState InsertNode ( WmiTreeNode *&a_Root , WmiTreeNode *&a_Node ) ;
  1368. WmiTriState RecursiveSortConditionals ( WmiTreeNode *&a_Root , WmiTreeNode *&a_NewRoot ) ;
  1369. WmiTriState SortConditionals ( WmiTreeNode *&a_Root ) ;
  1370. WmiTriState RecursiveSort ( WmiTreeNode *&a_Root ) ;
  1371. WmiTriState RecursiveConvertToRanges ( WmiTreeNode *&a_Root ) ;
  1372. QuadState RecursiveRemoveNonOverlappingRanges ( WmiTreeNode *&a_Root , WmiTreeNode *&a_Compare ) ;
  1373. void CountDisjunctions ( WmiTreeNode *a_Root , ULONG &a_Count ) ;
  1374. WmiTriState CreateDisjunctions (
  1375. void *a_Context ,
  1376. WmiTreeNode *a_Node ,
  1377. Disjunctions *a_Disjunctions ,
  1378. ULONG a_PropertiesToPartitionCount ,
  1379. BSTR *a_PropertiesToPartition ,
  1380. ULONG &a_DisjunctionIndex
  1381. ) ;
  1382. WmiTriState RecursivePartitionSet (
  1383. Disjunctions *a_Disjunctions ,
  1384. PartitionSet *&a_Partition ,
  1385. ULONG a_DisjunctionSetToTestCount ,
  1386. ULONG *a_DisjunctionSetToTest ,
  1387. ULONG a_KeyIndex
  1388. ) ;
  1389. protected:
  1390. /*
  1391. * Given a property name and it's value convert to it's correct type.
  1392. * e.g. if the CIMType of a_PropertyName is uint32 then create an WmiUnsignedIntegerNode
  1393. * return NULL if error.
  1394. */
  1395. virtual WmiTreeNode *AllocTypeNode (
  1396. void *a_Context ,
  1397. BSTR a_PropertyName ,
  1398. VARIANT &a_Variant ,
  1399. WmiValueNode :: WmiValueFunction a_PropertyFunction ,
  1400. WmiValueNode :: WmiValueFunction a_ConstantFunction ,
  1401. WmiTreeNode *a_Parent
  1402. ) ;
  1403. virtual QuadState InvariantEvaluate (
  1404. void *a_Context ,
  1405. WmiTreeNode *a_Operator ,
  1406. WmiTreeNode *a_Operand
  1407. ) { return State_Undefined ; }
  1408. virtual WmiRangeNode *AllocInfiniteRangeNode (
  1409. void *a_Context ,
  1410. BSTR a_PropertyName
  1411. ) { return NULL ; }
  1412. protected:
  1413. BOOL Evaluate (
  1414. void *a_Context ,
  1415. SQL_LEVEL_1_RPN_EXPRESSION &a_Expression ,
  1416. WmiTreeNode **a_Root
  1417. ) ;
  1418. QuadState DisjunctiveNormalForm ( WmiTreeNode *&a_Root ) ;
  1419. void RecursiveQuickSort (
  1420. WmiRangeNode **a_Array ,
  1421. ULONG *a_UnsortedOrder ,
  1422. ULONG a_Lower ,
  1423. ULONG a_Upper
  1424. ) ;
  1425. void QuickSort (
  1426. WmiRangeNode **a_Array ,
  1427. ULONG *a_UnsortedOrder ,
  1428. ULONG a_Size
  1429. ) ;
  1430. void SortRanges (
  1431. ULONG a_DisjunctionCount ,
  1432. ULONG *a_OriginToSorted ,
  1433. WmiRangeNode **a_RangeTable
  1434. ) ;
  1435. WmiTriState RemoveOverlaps (
  1436. ULONG *a_DisjunctionSetToTest ,
  1437. ULONG a_DisjunctionCount ,
  1438. ULONG *a_OverlappingIndex ,
  1439. ULONG *a_OriginToSorted ,
  1440. WmiRangeNode **a_RangeTable
  1441. ) ;
  1442. QuadState RemoveInvariants ( void *a_Context , WmiTreeNode *&a_Root ) ;
  1443. WmiTriState Sort ( WmiTreeNode *&a_Root ) ;
  1444. WmiTriState ConvertToRanges ( WmiTreeNode *&a_Root ) ;
  1445. QuadState RemoveNonOverlappingRanges ( WmiTreeNode *&a_Root ) ;
  1446. WmiTriState CreateDisjunctionContainer (
  1447. void *a_Context ,
  1448. WmiTreeNode *a_Root ,
  1449. ULONG a_Count ,
  1450. BSTR *a_Container ,
  1451. Disjunctions *&a_Disjunctions
  1452. ) ;
  1453. WmiTriState CreatePartitionSet (
  1454. Disjunctions *a_Disjunctions ,
  1455. PartitionSet *&a_Partition
  1456. ) ;
  1457. void PrintTree ( WmiTreeNode *a_Root ) ;
  1458. public:
  1459. QueryPreprocessor () ;
  1460. virtual ~QueryPreprocessor () ;
  1461. QuadState PreProcess (
  1462. void *a_Context ,
  1463. SQL_LEVEL_1_RPN_EXPRESSION *a_RpnExpression ,
  1464. WmiTreeNode *&a_Root
  1465. ) ;
  1466. QuadState PreProcess (
  1467. void *a_Context ,
  1468. SQL_LEVEL_1_RPN_EXPRESSION *a_RpnExpression ,
  1469. WmiTreeNode *a_Root ,
  1470. ULONG a_Count ,
  1471. BSTR *a_Container ,
  1472. PartitionSet *&a_Partition
  1473. ) ;
  1474. QuadState Query (
  1475. BSTR a_Query ,
  1476. SQL_LEVEL_1_RPN_EXPRESSION *&a_RpnExpression
  1477. ) ;
  1478. } ;
  1479. #endif