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.

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