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.

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