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.

10018 lines
212 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. ProvTree.cpp
  5. Abstract:
  6. History:
  7. --*/
  8. #include <precomp.h>
  9. #include <wbemint.h>
  10. #include <typeinfo.h>
  11. #include <stdio.h>
  12. #include <HelperFuncs.h>
  13. #include <Logging.h>
  14. #include "ProvDnf.h"
  15. #include "wbemutil.h"
  16. #include "autoptr.h"
  17. /******************************************************************************
  18. *
  19. * Name:
  20. *
  21. *
  22. * Description:
  23. *
  24. *
  25. *****************************************************************************/
  26. WmiOrNode :: ~WmiOrNode ()
  27. {
  28. delete m_Left ;
  29. delete m_Right ;
  30. }
  31. /******************************************************************************
  32. *
  33. * Name:
  34. *
  35. *
  36. * Description:
  37. *
  38. *
  39. *****************************************************************************/
  40. WmiAndNode :: ~WmiAndNode ()
  41. {
  42. delete m_Left ;
  43. delete m_Right ;
  44. }
  45. /******************************************************************************
  46. *
  47. * Name:
  48. *
  49. *
  50. * Description:
  51. *
  52. *
  53. *****************************************************************************/
  54. WmiNotNode :: ~WmiNotNode ()
  55. {
  56. delete m_Left ;
  57. }
  58. /******************************************************************************
  59. *
  60. * Name:
  61. *
  62. *
  63. * Description:
  64. *
  65. *
  66. *****************************************************************************/
  67. WmiOperatorEqualNode :: ~WmiOperatorEqualNode ()
  68. {
  69. delete m_Left ;
  70. }
  71. /******************************************************************************
  72. *
  73. * Name:
  74. *
  75. *
  76. * Description:
  77. *
  78. *
  79. *****************************************************************************/
  80. WmiOperatorNotEqualNode :: ~WmiOperatorNotEqualNode ()
  81. {
  82. delete m_Left ;
  83. }
  84. /******************************************************************************
  85. *
  86. * Name:
  87. *
  88. *
  89. * Description:
  90. *
  91. *
  92. *****************************************************************************/
  93. WmiOperatorEqualOrGreaterNode :: ~WmiOperatorEqualOrGreaterNode ()
  94. {
  95. delete m_Left ;
  96. }
  97. /******************************************************************************
  98. *
  99. * Name:
  100. *
  101. *
  102. * Description:
  103. *
  104. *
  105. *****************************************************************************/
  106. WmiOperatorEqualOrLessNode :: ~WmiOperatorEqualOrLessNode ()
  107. {
  108. delete m_Left ;
  109. }
  110. /******************************************************************************
  111. *
  112. * Name:
  113. *
  114. *
  115. * Description:
  116. *
  117. *
  118. *****************************************************************************/
  119. WmiOperatorGreaterNode :: ~WmiOperatorGreaterNode ()
  120. {
  121. delete m_Left ;
  122. }
  123. /******************************************************************************
  124. *
  125. * Name:
  126. *
  127. *
  128. * Description:
  129. *
  130. *
  131. *****************************************************************************/
  132. WmiOperatorLessNode :: ~WmiOperatorLessNode ()
  133. {
  134. delete m_Left ;
  135. }
  136. /******************************************************************************
  137. *
  138. * Name:
  139. *
  140. *
  141. * Description:
  142. *
  143. *
  144. *****************************************************************************/
  145. WmiOperatorLikeNode :: ~WmiOperatorLikeNode ()
  146. {
  147. delete m_Left ;
  148. }
  149. /******************************************************************************
  150. *
  151. * Name:
  152. *
  153. *
  154. * Description:
  155. *
  156. *
  157. *****************************************************************************/
  158. WmiOperatorNotLikeNode :: ~WmiOperatorNotLikeNode ()
  159. {
  160. delete m_Left ;
  161. }
  162. /******************************************************************************
  163. *
  164. * Name:
  165. *
  166. *
  167. * Description:
  168. *
  169. *
  170. *****************************************************************************/
  171. WmiOperatorIsANode :: ~WmiOperatorIsANode ()
  172. {
  173. delete m_Left ;
  174. }
  175. /******************************************************************************
  176. *
  177. * Name:
  178. *
  179. *
  180. * Description:
  181. *
  182. *
  183. *****************************************************************************/
  184. WmiOperatorNotIsANode :: ~WmiOperatorNotIsANode ()
  185. {
  186. delete m_Left ;
  187. }
  188. /******************************************************************************
  189. *
  190. * Name:
  191. *
  192. *
  193. * Description:
  194. *
  195. *
  196. *****************************************************************************/
  197. WmiTreeNode *WmiOrNode :: Copy ()
  198. {
  199. WmiTreeNode *t_LeftCopy = NULL ;
  200. if ( m_Left )
  201. {
  202. t_LeftCopy = m_Left->Copy () ;
  203. if ( t_LeftCopy == NULL )
  204. {
  205. return NULL ;
  206. }
  207. }
  208. WmiTreeNode *t_RightCopy = NULL ;
  209. if ( m_Right )
  210. {
  211. t_RightCopy = m_Right->Copy () ;
  212. if ( t_RightCopy == NULL )
  213. {
  214. delete t_LeftCopy ;
  215. return NULL ;
  216. }
  217. }
  218. void *t_DataCopy = m_Data ;
  219. WmiTreeNode *t_Parent = m_Parent ;
  220. WmiTreeNode *t_Node = new WmiOrNode ( t_LeftCopy , t_RightCopy , t_Parent ) ;
  221. if ( t_Node)
  222. {
  223. if ( t_LeftCopy )
  224. {
  225. t_LeftCopy->SetParent ( t_Node ) ;
  226. }
  227. if ( t_RightCopy )
  228. {
  229. t_RightCopy->SetParent ( t_Node ) ;
  230. }
  231. }
  232. else
  233. {
  234. delete t_LeftCopy ;
  235. delete t_RightCopy ;
  236. return 0;
  237. }
  238. return t_Node ;
  239. } ;
  240. /******************************************************************************
  241. *
  242. * Name:
  243. *
  244. *
  245. * Description:
  246. *
  247. *
  248. *****************************************************************************/
  249. WmiTreeNode *WmiAndNode :: Copy ()
  250. {
  251. WmiTreeNode *t_LeftCopy = NULL ;
  252. if ( m_Left )
  253. {
  254. t_LeftCopy = m_Left->Copy () ;
  255. if ( t_LeftCopy == NULL )
  256. {
  257. return NULL ;
  258. }
  259. }
  260. WmiTreeNode *t_RightCopy = NULL ;
  261. if ( m_Right )
  262. {
  263. t_RightCopy = m_Right->Copy () ;
  264. if ( t_RightCopy == NULL )
  265. {
  266. delete t_LeftCopy ;
  267. return NULL ;
  268. }
  269. }
  270. void *t_DataCopy = m_Data ;
  271. WmiTreeNode *t_Parent = m_Parent ;
  272. WmiTreeNode *t_Node = new WmiAndNode ( t_LeftCopy , t_RightCopy , t_Parent ) ;
  273. if ( t_Node )
  274. {
  275. if ( t_LeftCopy )
  276. {
  277. t_LeftCopy->SetParent ( t_Node ) ;
  278. }
  279. if ( t_RightCopy )
  280. {
  281. t_RightCopy->SetParent ( t_Node ) ;
  282. }
  283. }
  284. else
  285. {
  286. delete t_LeftCopy ;
  287. delete t_RightCopy ;
  288. return 0;
  289. }
  290. return t_Node ;
  291. } ;
  292. /******************************************************************************
  293. *
  294. * Name:
  295. *
  296. *
  297. * Description:
  298. *
  299. *
  300. *****************************************************************************/
  301. WmiTreeNode *WmiNotNode :: Copy ()
  302. {
  303. WmiTreeNode *t_LeftCopy = NULL ;
  304. if ( m_Left )
  305. {
  306. t_LeftCopy = m_Left->Copy () ;
  307. if ( t_LeftCopy == NULL )
  308. {
  309. return NULL ;
  310. }
  311. }
  312. WmiTreeNode *t_Parent = m_Parent ;
  313. WmiTreeNode *t_Node = new WmiNotNode ( t_LeftCopy , t_Parent ) ;
  314. if ( t_Node)
  315. {
  316. if ( t_LeftCopy )
  317. {
  318. t_LeftCopy->SetParent ( t_Node ) ;
  319. }
  320. }
  321. else
  322. {
  323. delete t_LeftCopy ;
  324. return 0;
  325. }
  326. return t_Node ;
  327. } ;
  328. /******************************************************************************
  329. *
  330. * Name:
  331. *
  332. *
  333. * Description:
  334. *
  335. *
  336. *****************************************************************************/
  337. WmiTreeNode *WmiOperatorEqualNode :: Copy ()
  338. {
  339. WmiTreeNode *t_LeftCopy = NULL ;
  340. if ( m_Left )
  341. {
  342. t_LeftCopy = m_Left->Copy () ;
  343. if ( t_LeftCopy == NULL )
  344. {
  345. return NULL ;
  346. }
  347. }
  348. WmiTreeNode *t_Parent = m_Parent ;
  349. WmiTreeNode *t_Node = new WmiOperatorEqualNode ( t_LeftCopy , t_Parent ) ;
  350. if ( t_Node)
  351. {
  352. if ( t_LeftCopy )
  353. {
  354. t_LeftCopy->SetParent ( t_Node ) ;
  355. }
  356. }
  357. else
  358. {
  359. delete t_LeftCopy ;
  360. return 0;
  361. }
  362. return t_Node ;
  363. }
  364. /******************************************************************************
  365. *
  366. * Name:
  367. *
  368. *
  369. * Description:
  370. *
  371. *
  372. *****************************************************************************/
  373. WmiTreeNode *WmiOperatorNotEqualNode :: Copy ()
  374. {
  375. WmiTreeNode *t_LeftCopy = NULL ;
  376. if ( m_Left )
  377. {
  378. t_LeftCopy = m_Left->Copy () ;
  379. if ( t_LeftCopy == NULL )
  380. {
  381. return NULL ;
  382. }
  383. }
  384. WmiTreeNode *t_Parent = m_Parent ;
  385. WmiTreeNode *t_Node = new WmiOperatorNotEqualNode ( t_LeftCopy , t_Parent ) ;
  386. if ( t_Node)
  387. {
  388. if ( t_LeftCopy )
  389. {
  390. t_LeftCopy->SetParent ( t_Node ) ;
  391. }
  392. }
  393. else
  394. {
  395. delete t_LeftCopy ;
  396. return 0;
  397. }
  398. return t_Node ;
  399. }
  400. /******************************************************************************
  401. *
  402. * Name:
  403. *
  404. *
  405. * Description:
  406. *
  407. *
  408. *****************************************************************************/
  409. WmiTreeNode *WmiOperatorEqualOrGreaterNode :: Copy ()
  410. {
  411. WmiTreeNode *t_LeftCopy = NULL ;
  412. if ( m_Left )
  413. {
  414. t_LeftCopy = m_Left->Copy () ;
  415. if ( t_LeftCopy == NULL )
  416. {
  417. return NULL ;
  418. }
  419. }
  420. WmiTreeNode *t_Parent = m_Parent ;
  421. WmiTreeNode *t_Node = new WmiOperatorEqualOrGreaterNode ( t_LeftCopy , t_Parent ) ;
  422. if ( t_Node)
  423. {
  424. if ( t_LeftCopy )
  425. {
  426. t_LeftCopy->SetParent ( t_Node ) ;
  427. }
  428. }
  429. else
  430. {
  431. delete t_LeftCopy ;
  432. return 0;
  433. }
  434. return t_Node ;
  435. }
  436. /******************************************************************************
  437. *
  438. * Name:
  439. *
  440. *
  441. * Description:
  442. *
  443. *
  444. *****************************************************************************/
  445. WmiTreeNode *WmiOperatorEqualOrLessNode :: Copy ()
  446. {
  447. WmiTreeNode *t_LeftCopy = NULL ;
  448. if ( m_Left )
  449. {
  450. t_LeftCopy = m_Left->Copy () ;
  451. if ( t_LeftCopy == NULL )
  452. {
  453. return NULL ;
  454. }
  455. }
  456. WmiTreeNode *t_Parent = m_Parent ;
  457. WmiTreeNode *t_Node = new WmiOperatorEqualOrLessNode ( t_LeftCopy , t_Parent ) ;
  458. if ( t_Node )
  459. {
  460. if ( t_LeftCopy )
  461. {
  462. t_LeftCopy->SetParent ( t_Node ) ;
  463. }
  464. }
  465. else
  466. {
  467. delete t_LeftCopy ;
  468. return 0;
  469. }
  470. return t_Node ;
  471. }
  472. /******************************************************************************
  473. *
  474. * Name:
  475. *
  476. *
  477. * Description:
  478. *
  479. *
  480. *****************************************************************************/
  481. WmiTreeNode *WmiOperatorGreaterNode :: Copy ()
  482. {
  483. WmiTreeNode *t_LeftCopy = NULL ;
  484. if ( m_Left )
  485. {
  486. t_LeftCopy = m_Left->Copy () ;
  487. if ( t_LeftCopy == NULL )
  488. {
  489. return NULL ;
  490. }
  491. }
  492. WmiTreeNode *t_Parent = m_Parent ;
  493. WmiTreeNode *t_Node = new WmiOperatorGreaterNode ( t_LeftCopy , t_Parent ) ;
  494. if ( t_Node )
  495. {
  496. if ( t_LeftCopy )
  497. {
  498. t_LeftCopy->SetParent ( t_Node ) ;
  499. }
  500. }
  501. else
  502. {
  503. delete t_LeftCopy ;
  504. return 0;
  505. }
  506. return t_Node ;
  507. }
  508. /******************************************************************************
  509. *
  510. * Name:
  511. *
  512. *
  513. * Description:
  514. *
  515. *
  516. *****************************************************************************/
  517. WmiTreeNode *WmiOperatorLessNode :: Copy ()
  518. {
  519. WmiTreeNode *t_LeftCopy = NULL ;
  520. if ( m_Left )
  521. {
  522. t_LeftCopy = m_Left->Copy () ;
  523. if ( t_LeftCopy == NULL )
  524. {
  525. return NULL ;
  526. }
  527. }
  528. WmiTreeNode *t_Parent = m_Parent ;
  529. WmiTreeNode *t_Node = new WmiOperatorLessNode ( t_LeftCopy , t_Parent ) ;
  530. if ( t_Node )
  531. {
  532. if ( t_LeftCopy )
  533. {
  534. t_LeftCopy->SetParent ( t_Node ) ;
  535. }
  536. }
  537. else
  538. {
  539. delete t_LeftCopy ;
  540. return 0;
  541. }
  542. return t_Node ;
  543. }
  544. /******************************************************************************
  545. *
  546. * Name:
  547. *
  548. *
  549. * Description:
  550. *
  551. *
  552. *****************************************************************************/
  553. WmiTreeNode *WmiOperatorLikeNode :: Copy ()
  554. {
  555. WmiTreeNode *t_LeftCopy = NULL ;
  556. if ( m_Left )
  557. {
  558. t_LeftCopy = m_Left->Copy () ;
  559. if ( t_LeftCopy == NULL )
  560. {
  561. return NULL ;
  562. }
  563. }
  564. WmiTreeNode *t_Parent = m_Parent ;
  565. WmiTreeNode *t_Node = new WmiOperatorLikeNode ( t_LeftCopy , t_Parent ) ;
  566. if ( t_Node )
  567. {
  568. if ( t_LeftCopy )
  569. {
  570. t_LeftCopy->SetParent ( t_Node ) ;
  571. }
  572. }
  573. else
  574. {
  575. delete t_LeftCopy ;
  576. return 0;
  577. }
  578. return t_Node ;
  579. }
  580. /******************************************************************************
  581. *
  582. * Name:
  583. *
  584. *
  585. * Description:
  586. *
  587. *
  588. *****************************************************************************/
  589. WmiTreeNode *WmiOperatorNotLikeNode :: Copy ()
  590. {
  591. WmiTreeNode *t_LeftCopy = NULL ;
  592. if ( m_Left )
  593. {
  594. t_LeftCopy = m_Left->Copy () ;
  595. if ( t_LeftCopy == NULL )
  596. {
  597. return NULL ;
  598. }
  599. }
  600. WmiTreeNode *t_Parent = m_Parent ;
  601. WmiTreeNode *t_Node = new WmiOperatorNotLikeNode ( t_LeftCopy , t_Parent ) ;
  602. if ( t_Node )
  603. {
  604. if ( t_LeftCopy )
  605. {
  606. t_LeftCopy->SetParent ( t_Node ) ;
  607. }
  608. }
  609. else
  610. {
  611. delete t_LeftCopy ;
  612. return 0;
  613. }
  614. return t_Node ;
  615. }
  616. /******************************************************************************
  617. *
  618. * Name:
  619. *
  620. *
  621. * Description:
  622. *
  623. *
  624. *****************************************************************************/
  625. WmiTreeNode *WmiOperatorIsANode :: Copy ()
  626. {
  627. WmiTreeNode *t_LeftCopy = NULL ;
  628. if ( m_Left )
  629. {
  630. t_LeftCopy = m_Left->Copy () ;
  631. if ( t_LeftCopy == NULL )
  632. {
  633. return NULL ;
  634. }
  635. }
  636. WmiTreeNode *t_Parent = m_Parent ;
  637. WmiTreeNode *t_Node = new WmiOperatorIsANode ( t_LeftCopy , t_Parent ) ;
  638. if ( t_Node )
  639. {
  640. if ( t_LeftCopy )
  641. {
  642. t_LeftCopy->SetParent ( t_Node ) ;
  643. }
  644. }
  645. else
  646. {
  647. delete t_LeftCopy ;
  648. return 0;
  649. }
  650. return t_Node ;
  651. }
  652. /******************************************************************************
  653. *
  654. * Name:
  655. *
  656. *
  657. * Description:
  658. *
  659. *
  660. *****************************************************************************/
  661. WmiTreeNode *WmiOperatorNotIsANode :: Copy ()
  662. {
  663. WmiTreeNode *t_LeftCopy = NULL ;
  664. if ( m_Left )
  665. {
  666. t_LeftCopy = m_Left->Copy () ;
  667. if ( t_LeftCopy == NULL )
  668. {
  669. return NULL ;
  670. }
  671. }
  672. WmiTreeNode *t_Parent = m_Parent ;
  673. WmiTreeNode *t_Node = new WmiOperatorNotIsANode ( t_LeftCopy , t_Parent ) ;
  674. if ( t_Node )
  675. {
  676. if ( t_LeftCopy )
  677. {
  678. t_LeftCopy->SetParent ( t_Node ) ;
  679. }
  680. }
  681. else
  682. {
  683. delete t_LeftCopy ;
  684. return 0;
  685. }
  686. return t_Node ;
  687. }
  688. /******************************************************************************
  689. *
  690. * Name:
  691. *
  692. *
  693. * Description:
  694. *
  695. *
  696. *****************************************************************************/
  697. WmiTreeNode *WmiSignedIntegerNode :: Copy ()
  698. {
  699. WmiTreeNode *t_Parent = m_Parent ;
  700. WmiTreeNode *t_Node = new WmiSignedIntegerNode ( m_PropertyName , m_Integer , m_Index , t_Parent ) ;
  701. if (t_Node && t_Node->IsValid()) return t_Node;
  702. delete t_Node;
  703. return 0;
  704. }
  705. /******************************************************************************
  706. *
  707. * Name:
  708. *
  709. *
  710. * Description:
  711. *
  712. *
  713. *****************************************************************************/
  714. WmiTreeNode *WmiUnsignedIntegerNode :: Copy ()
  715. {
  716. WmiTreeNode *t_Parent = m_Parent ;
  717. WmiTreeNode *t_Node = new WmiUnsignedIntegerNode ( m_PropertyName , m_Integer , m_Index , t_Parent ) ;
  718. if (t_Node && t_Node->IsValid()) return t_Node;
  719. delete t_Node;
  720. return 0;
  721. }
  722. /******************************************************************************
  723. *
  724. * Name:
  725. *
  726. *
  727. * Description:
  728. *
  729. *
  730. *****************************************************************************/
  731. WmiTreeNode *WmiStringNode :: Copy ()
  732. {
  733. WmiTreeNode *t_Parent = m_Parent ;
  734. WmiTreeNode *t_Node = new WmiStringNode ( m_PropertyName , m_String , m_PropertyFunction , m_ConstantFunction , m_Index , t_Parent ) ;
  735. if (t_Node && t_Node->IsValid()) return t_Node;
  736. delete t_Node;
  737. return 0;
  738. }
  739. /******************************************************************************
  740. *
  741. * Name:
  742. *
  743. *
  744. * Description:
  745. *
  746. *
  747. *****************************************************************************/
  748. WmiTreeNode *WmiNullNode :: Copy ()
  749. {
  750. WmiTreeNode *t_Parent = m_Parent ;
  751. WmiTreeNode *t_Node = new WmiNullNode ( m_PropertyName , m_Index , t_Parent ) ;
  752. if (t_Node && t_Node->IsValid()) return t_Node;
  753. delete t_Node;
  754. return 0;
  755. }
  756. /******************************************************************************
  757. *
  758. * Name:
  759. *
  760. *
  761. * Description:
  762. *
  763. *
  764. *****************************************************************************/
  765. WmiTreeNode *WmiSignedIntegerRangeNode :: Copy ()
  766. {
  767. WmiTreeNode *t_Node = new WmiSignedIntegerRangeNode (
  768. m_PropertyName ,
  769. m_Index ,
  770. m_InfiniteLowerBound ,
  771. m_InfiniteUpperBound ,
  772. m_LowerBoundClosed ,
  773. m_UpperBoundClosed ,
  774. m_LowerBound ,
  775. m_UpperBound ,
  776. NULL ,
  777. NULL
  778. ) ;
  779. if (t_Node && t_Node->IsValid()) return t_Node;
  780. delete t_Node;
  781. return 0;
  782. }
  783. /******************************************************************************
  784. *
  785. * Name:
  786. *
  787. *
  788. * Description:
  789. *
  790. *
  791. *****************************************************************************/
  792. WmiTreeNode *WmiUnsignedIntegerRangeNode :: Copy ()
  793. {
  794. WmiTreeNode *t_Node = new WmiUnsignedIntegerRangeNode (
  795. m_PropertyName ,
  796. m_Index ,
  797. m_InfiniteLowerBound ,
  798. m_InfiniteUpperBound ,
  799. m_LowerBoundClosed ,
  800. m_UpperBoundClosed ,
  801. m_LowerBound ,
  802. m_UpperBound ,
  803. NULL ,
  804. NULL
  805. ) ;
  806. if (t_Node && t_Node->IsValid()) return t_Node;
  807. delete t_Node;
  808. return 0;
  809. }
  810. /******************************************************************************
  811. *
  812. * Name:
  813. *
  814. *
  815. * Description:
  816. *
  817. *
  818. *****************************************************************************/
  819. WmiTreeNode *WmiStringRangeNode :: Copy ()
  820. {
  821. WmiTreeNode *t_Node = new WmiStringRangeNode (
  822. m_PropertyName ,
  823. m_Index ,
  824. m_InfiniteLowerBound ,
  825. m_InfiniteUpperBound ,
  826. m_LowerBoundClosed ,
  827. m_UpperBoundClosed ,
  828. m_LowerBound ,
  829. m_UpperBound ,
  830. NULL ,
  831. NULL
  832. ) ;
  833. if (t_Node && t_Node->IsValid()) return t_Node;
  834. delete t_Node;
  835. return 0;
  836. }
  837. /******************************************************************************
  838. *
  839. * Name:
  840. *
  841. *
  842. * Description:
  843. *
  844. *
  845. *****************************************************************************/
  846. WmiTreeNode *WmiNullRangeNode :: Copy ()
  847. {
  848. WmiTreeNode *t_Node = new WmiNullRangeNode ( m_PropertyName , m_Index , NULL , NULL ) ;
  849. if (t_Node && t_Node->IsValid()) return t_Node;
  850. delete t_Node;
  851. return 0;
  852. }
  853. /******************************************************************************
  854. *
  855. * Name:
  856. *
  857. *
  858. * Description:
  859. *
  860. *
  861. *****************************************************************************/
  862. void WmiOrNode :: Print ()
  863. {
  864. DebugMacro3(
  865. WmiDebugLog :: s_WmiDebugLog->Write (
  866. L" ( "
  867. ) ;
  868. )
  869. if ( GetLeft () )
  870. GetLeft ()->Print () ;
  871. DebugMacro3(
  872. WmiDebugLog :: s_WmiDebugLog->Write (
  873. L" ) "
  874. ) ;
  875. )
  876. DebugMacro3(
  877. WmiDebugLog :: s_WmiDebugLog->Write (
  878. L" Or "
  879. ) ;
  880. )
  881. DebugMacro3(
  882. WmiDebugLog :: s_WmiDebugLog->Write (
  883. L" ( "
  884. ) ;
  885. )
  886. if ( GetRight () )
  887. GetRight ()->Print () ;
  888. DebugMacro3(
  889. WmiDebugLog :: s_WmiDebugLog->Write (
  890. L" ) "
  891. ) ;
  892. )
  893. }
  894. /******************************************************************************
  895. *
  896. * Name:
  897. *
  898. *
  899. * Description:
  900. *
  901. *
  902. *****************************************************************************/
  903. void WmiAndNode :: Print ()
  904. {
  905. DebugMacro3(
  906. WmiDebugLog :: s_WmiDebugLog->Write (
  907. L" ( "
  908. ) ;
  909. )
  910. if ( GetLeft () )
  911. GetLeft ()->Print () ;
  912. DebugMacro3(
  913. WmiDebugLog :: s_WmiDebugLog->Write (
  914. L" ) "
  915. ) ;
  916. )
  917. DebugMacro3(
  918. WmiDebugLog :: s_WmiDebugLog->Write (
  919. L" And "
  920. ) ;
  921. )
  922. DebugMacro3(
  923. WmiDebugLog :: s_WmiDebugLog->Write (
  924. L" ( "
  925. ) ;
  926. )
  927. if ( GetRight () )
  928. GetRight ()->Print () ;
  929. DebugMacro3(
  930. WmiDebugLog :: s_WmiDebugLog->Write (
  931. L" ) "
  932. ) ;
  933. )
  934. }
  935. /******************************************************************************
  936. *
  937. * Name:
  938. *
  939. *
  940. * Description:
  941. *
  942. *
  943. *****************************************************************************/
  944. void WmiNotNode :: Print ()
  945. {
  946. DebugMacro3(
  947. WmiDebugLog :: s_WmiDebugLog->Write (
  948. L"Not"
  949. ) ;
  950. )
  951. DebugMacro3(
  952. WmiDebugLog :: s_WmiDebugLog->Write (
  953. L" ( "
  954. ) ;
  955. )
  956. if ( GetLeft () )
  957. GetLeft ()->Print () ;
  958. DebugMacro3(
  959. WmiDebugLog :: s_WmiDebugLog->Write (
  960. L" ) "
  961. ) ;
  962. )
  963. }
  964. /******************************************************************************
  965. *
  966. * Name:
  967. *
  968. *
  969. * Description:
  970. *
  971. *
  972. *****************************************************************************/
  973. void WmiOperatorEqualNode :: Print ()
  974. {
  975. DebugMacro3(
  976. WmiDebugLog :: s_WmiDebugLog->Write (
  977. L" = "
  978. ) ;
  979. )
  980. if ( GetLeft () )
  981. GetLeft ()->Print () ;
  982. }
  983. /******************************************************************************
  984. *
  985. * Name:
  986. *
  987. *
  988. * Description:
  989. *
  990. *
  991. *****************************************************************************/
  992. void WmiOperatorNotEqualNode :: Print ()
  993. {
  994. DebugMacro3(
  995. WmiDebugLog :: s_WmiDebugLog->Write (
  996. L" != "
  997. ) ;
  998. )
  999. if ( GetLeft () )
  1000. GetLeft ()->Print () ;
  1001. }
  1002. /******************************************************************************
  1003. *
  1004. * Name:
  1005. *
  1006. *
  1007. * Description:
  1008. *
  1009. *
  1010. *****************************************************************************/
  1011. void WmiOperatorEqualOrGreaterNode :: Print ()
  1012. {
  1013. DebugMacro3(
  1014. WmiDebugLog :: s_WmiDebugLog->Write (
  1015. L" >= "
  1016. ) ;
  1017. )
  1018. if ( GetLeft () )
  1019. GetLeft ()->Print () ;
  1020. }
  1021. /******************************************************************************
  1022. *
  1023. * Name:
  1024. *
  1025. *
  1026. * Description:
  1027. *
  1028. *
  1029. *****************************************************************************/
  1030. void WmiOperatorEqualOrLessNode :: Print ()
  1031. {
  1032. DebugMacro3(
  1033. WmiDebugLog :: s_WmiDebugLog->Write (
  1034. L" <= "
  1035. ) ;
  1036. )
  1037. if ( GetLeft () )
  1038. GetLeft ()->Print () ;
  1039. }
  1040. /******************************************************************************
  1041. *
  1042. * Name:
  1043. *
  1044. *
  1045. * Description:
  1046. *
  1047. *
  1048. *****************************************************************************/
  1049. void WmiOperatorLessNode :: Print ()
  1050. {
  1051. DebugMacro3(
  1052. WmiDebugLog :: s_WmiDebugLog->Write (
  1053. L" < "
  1054. ) ;
  1055. )
  1056. if ( GetLeft () )
  1057. GetLeft ()->Print () ;
  1058. }
  1059. /******************************************************************************
  1060. *
  1061. * Name:
  1062. *
  1063. *
  1064. * Description:
  1065. *
  1066. *
  1067. *****************************************************************************/
  1068. void WmiOperatorGreaterNode :: Print ()
  1069. {
  1070. DebugMacro3(
  1071. WmiDebugLog :: s_WmiDebugLog->Write (
  1072. L" > "
  1073. ) ;
  1074. )
  1075. if ( GetLeft () )
  1076. GetLeft ()->Print () ;
  1077. }
  1078. /******************************************************************************
  1079. *
  1080. * Name:
  1081. *
  1082. *
  1083. * Description:
  1084. *
  1085. *
  1086. *****************************************************************************/
  1087. void WmiOperatorLikeNode :: Print ()
  1088. {
  1089. DebugMacro3(
  1090. WmiDebugLog :: s_WmiDebugLog->Write (
  1091. L" Like "
  1092. ) ;
  1093. )
  1094. if ( GetLeft () )
  1095. GetLeft ()->Print () ;
  1096. }
  1097. /******************************************************************************
  1098. *
  1099. * Name:
  1100. *
  1101. *
  1102. * Description:
  1103. *
  1104. *
  1105. *****************************************************************************/
  1106. void WmiOperatorNotLikeNode :: Print ()
  1107. {
  1108. DebugMacro3(
  1109. WmiDebugLog :: s_WmiDebugLog->Write (
  1110. L" NotLike "
  1111. ) ;
  1112. )
  1113. if ( GetLeft () )
  1114. GetLeft ()->Print () ;
  1115. }
  1116. /******************************************************************************
  1117. *
  1118. * Name:
  1119. *
  1120. *
  1121. * Description:
  1122. *
  1123. *
  1124. *****************************************************************************/
  1125. void WmiOperatorIsANode :: Print ()
  1126. {
  1127. DebugMacro3(
  1128. WmiDebugLog :: s_WmiDebugLog->Write (
  1129. L" IsA "
  1130. ) ;
  1131. )
  1132. if ( GetLeft () )
  1133. GetLeft ()->Print () ;
  1134. }
  1135. /******************************************************************************
  1136. *
  1137. * Name:
  1138. *
  1139. *
  1140. * Description:
  1141. *
  1142. *
  1143. *****************************************************************************/
  1144. void WmiOperatorNotIsANode :: Print ()
  1145. {
  1146. DebugMacro3(
  1147. WmiDebugLog :: s_WmiDebugLog->Write (
  1148. L" Not IsA "
  1149. ) ;
  1150. )
  1151. if ( GetLeft () )
  1152. GetLeft ()->Print () ;
  1153. }
  1154. /******************************************************************************
  1155. *
  1156. * Name:
  1157. *
  1158. *
  1159. * Description:
  1160. *
  1161. *
  1162. *****************************************************************************/
  1163. void WmiStringNode :: Print ()
  1164. {
  1165. DebugMacro3(
  1166. WmiDebugLog :: s_WmiDebugLog->Write (
  1167. L" ( %s , %s ) " ,
  1168. GetPropertyName () ,
  1169. GetValue ()
  1170. ) ;
  1171. )
  1172. }
  1173. /******************************************************************************
  1174. *
  1175. * Name:
  1176. *
  1177. *
  1178. * Description:
  1179. *
  1180. *
  1181. *****************************************************************************/
  1182. void WmiUnsignedIntegerNode :: Print ()
  1183. {
  1184. DebugMacro3(
  1185. WmiDebugLog :: s_WmiDebugLog->Write (
  1186. L" ( %s , %ld ) " ,
  1187. GetPropertyName () ,
  1188. GetValue ()
  1189. ) ;
  1190. )
  1191. }
  1192. /******************************************************************************
  1193. *
  1194. * Name:
  1195. *
  1196. *
  1197. * Description:
  1198. *
  1199. *
  1200. *****************************************************************************/
  1201. void WmiSignedIntegerNode :: Print ()
  1202. {
  1203. DebugMacro3(
  1204. WmiDebugLog :: s_WmiDebugLog->Write (
  1205. L" ( %s , %d ) " ,
  1206. GetPropertyName () ,
  1207. GetValue ()
  1208. ) ;
  1209. )
  1210. }
  1211. /******************************************************************************
  1212. *
  1213. * Name:
  1214. *
  1215. *
  1216. * Description:
  1217. *
  1218. *
  1219. *****************************************************************************/
  1220. void WmiNullNode :: Print ()
  1221. {
  1222. DebugMacro3(
  1223. WmiDebugLog :: s_WmiDebugLog->Write (
  1224. L" ( %s , NULL ) " ,
  1225. GetPropertyName ()
  1226. ) ;
  1227. )
  1228. }
  1229. /******************************************************************************
  1230. *
  1231. * Name:
  1232. *
  1233. *
  1234. * Description:
  1235. *
  1236. *
  1237. *****************************************************************************/
  1238. void WmiStringRangeNode :: Print ()
  1239. {
  1240. DebugMacro3(
  1241. WmiDebugLog :: s_WmiDebugLog->Write (
  1242. L" ( %s , %s , %s , %s , %s , %s , %s ) " ,
  1243. GetPropertyName () ,
  1244. m_InfiniteLowerBound ? L"Infinite" : L"Finite",
  1245. m_InfiniteUpperBound ? L"Infinite" : L"Finite",
  1246. m_LowerBoundClosed ? L"Closed" : L"Open" ,
  1247. m_UpperBoundClosed ? L"Closed" : L"Open",
  1248. m_InfiniteLowerBound ? L"" : m_LowerBound ,
  1249. m_InfiniteUpperBound ? L"" : m_UpperBound
  1250. ) ;
  1251. )
  1252. }
  1253. /******************************************************************************
  1254. *
  1255. * Name:
  1256. *
  1257. *
  1258. * Description:
  1259. *
  1260. *
  1261. *****************************************************************************/
  1262. void WmiUnsignedIntegerRangeNode :: Print ()
  1263. {
  1264. DebugMacro3(
  1265. WmiDebugLog :: s_WmiDebugLog->Write (
  1266. L" ( %s , %s , %s , %s , %s , %lu , %lu ) " ,
  1267. GetPropertyName () ,
  1268. m_InfiniteLowerBound ? L"Infinite" : L"Finite",
  1269. m_InfiniteUpperBound ? L"Infinite" : L"Finite",
  1270. m_LowerBoundClosed ? L"Closed" : L"Open" ,
  1271. m_UpperBoundClosed ? L"Closed" : L"Open",
  1272. m_InfiniteLowerBound ? 0 : m_LowerBound ,
  1273. m_InfiniteUpperBound ? 0 : m_UpperBound
  1274. ) ;
  1275. )
  1276. }
  1277. /******************************************************************************
  1278. *
  1279. * Name:
  1280. *
  1281. *
  1282. * Description:
  1283. *
  1284. *
  1285. *****************************************************************************/
  1286. void WmiSignedIntegerRangeNode :: Print ()
  1287. {
  1288. DebugMacro3(
  1289. WmiDebugLog :: s_WmiDebugLog->Write (
  1290. L" ( %s , %s , %s , %s , %s , %ld , %ld ) " ,
  1291. GetPropertyName () ,
  1292. m_InfiniteLowerBound ? L"Infinite" : L"Finite",
  1293. m_InfiniteUpperBound ? L"Infinite" : L"Finite",
  1294. m_LowerBoundClosed ? L"Closed" : L"Open" ,
  1295. m_UpperBoundClosed ? L"Closed" : L"Open",
  1296. m_InfiniteLowerBound ? 0 : m_LowerBound ,
  1297. m_InfiniteUpperBound ? 0 : m_UpperBound
  1298. ) ;
  1299. )
  1300. }
  1301. /******************************************************************************
  1302. *
  1303. * Name:
  1304. *
  1305. *
  1306. * Description:
  1307. *
  1308. *
  1309. *****************************************************************************/
  1310. void WmiNullRangeNode :: Print ()
  1311. {
  1312. DebugMacro3(
  1313. WmiDebugLog :: s_WmiDebugLog->Write (
  1314. L" ( %s , NULL ) " ,
  1315. GetPropertyName ()
  1316. ) ;
  1317. )
  1318. }
  1319. /******************************************************************************
  1320. *
  1321. * Name:
  1322. *
  1323. *
  1324. * Description:
  1325. *
  1326. *
  1327. *****************************************************************************/
  1328. BOOL CompareUnsignedIntegerLess (
  1329. ULONG X ,
  1330. LONG X_INFINITE ,
  1331. ULONG Y ,
  1332. LONG Y_INFINITE
  1333. )
  1334. {
  1335. if ( X_INFINITE < 0 )
  1336. {
  1337. if ( Y_INFINITE < 0 )
  1338. {
  1339. return FALSE ;
  1340. }
  1341. else if ( Y_INFINITE == 0 )
  1342. {
  1343. return TRUE ;
  1344. }
  1345. else
  1346. {
  1347. return TRUE ;
  1348. }
  1349. }
  1350. else if ( X_INFINITE == 0 )
  1351. {
  1352. if ( Y_INFINITE < 0 )
  1353. {
  1354. return FALSE ;
  1355. }
  1356. else if ( Y_INFINITE == 0 )
  1357. {
  1358. return X < Y ;
  1359. }
  1360. else
  1361. {
  1362. return TRUE ;
  1363. }
  1364. }
  1365. else
  1366. {
  1367. return FALSE ;
  1368. }
  1369. }
  1370. /******************************************************************************
  1371. *
  1372. * Name:
  1373. *
  1374. *
  1375. * Description:
  1376. *
  1377. *
  1378. *****************************************************************************/
  1379. BOOL CompareUnsignedIntegerLessOrEqual (
  1380. ULONG X ,
  1381. LONG X_INFINITE ,
  1382. ULONG Y ,
  1383. LONG Y_INFINITE
  1384. )
  1385. {
  1386. if ( X_INFINITE < 0 )
  1387. {
  1388. if ( Y_INFINITE < 0 )
  1389. {
  1390. return TRUE ;
  1391. }
  1392. else if ( Y_INFINITE == 0 )
  1393. {
  1394. return TRUE ;
  1395. }
  1396. else
  1397. {
  1398. return TRUE ;
  1399. }
  1400. }
  1401. else if ( X_INFINITE == 0 )
  1402. {
  1403. if ( Y_INFINITE < 0 )
  1404. {
  1405. return FALSE ;
  1406. }
  1407. else if ( Y_INFINITE == 0 )
  1408. {
  1409. return X <= Y ;
  1410. }
  1411. else
  1412. {
  1413. return TRUE ;
  1414. }
  1415. }
  1416. else
  1417. {
  1418. if ( Y_INFINITE > 0 )
  1419. {
  1420. return TRUE ;
  1421. }
  1422. else
  1423. {
  1424. return FALSE ;
  1425. }
  1426. }
  1427. }
  1428. /******************************************************************************
  1429. *
  1430. * Name:
  1431. *
  1432. *
  1433. * Description:
  1434. *
  1435. *
  1436. *****************************************************************************/
  1437. BOOL CompareUnsignedIntegerGreater (
  1438. ULONG X ,
  1439. LONG X_INFINITE ,
  1440. ULONG Y ,
  1441. LONG Y_INFINITE
  1442. )
  1443. {
  1444. if ( X_INFINITE < 0 )
  1445. {
  1446. return FALSE ;
  1447. }
  1448. else if ( X_INFINITE == 0 )
  1449. {
  1450. if ( Y_INFINITE < 0 )
  1451. {
  1452. return TRUE ;
  1453. }
  1454. else if ( Y_INFINITE == 0 )
  1455. {
  1456. return X > Y ;
  1457. }
  1458. else
  1459. {
  1460. return FALSE ;
  1461. }
  1462. }
  1463. else
  1464. {
  1465. if ( Y_INFINITE < 0 )
  1466. {
  1467. return TRUE ;
  1468. }
  1469. else if ( Y_INFINITE == 0 )
  1470. {
  1471. return TRUE ;
  1472. }
  1473. else
  1474. {
  1475. return FALSE ;
  1476. }
  1477. }
  1478. }
  1479. /******************************************************************************
  1480. *
  1481. * Name:
  1482. *
  1483. *
  1484. * Description:
  1485. *
  1486. *
  1487. *****************************************************************************/
  1488. BOOL CompareUnsignedIntegerEqual (
  1489. ULONG X ,
  1490. LONG X_INFINITE ,
  1491. ULONG Y ,
  1492. LONG Y_INFINITE
  1493. )
  1494. {
  1495. if ( X_INFINITE < 0 && Y_INFINITE < 0 )
  1496. {
  1497. return TRUE ;
  1498. }
  1499. else if ( X_INFINITE == 0 && Y_INFINITE == 0 )
  1500. {
  1501. return X == Y ;
  1502. }
  1503. else if ( X_INFINITE > 0 && Y_INFINITE > 0 )
  1504. {
  1505. return TRUE ;
  1506. }
  1507. else
  1508. {
  1509. return FALSE ;
  1510. }
  1511. }
  1512. /******************************************************************************
  1513. *
  1514. * Name:
  1515. *
  1516. *
  1517. * Description:
  1518. *
  1519. *
  1520. *****************************************************************************/
  1521. BOOL CompareSignedIntegerLess (
  1522. LONG X ,
  1523. LONG X_INFINITE ,
  1524. LONG Y ,
  1525. LONG Y_INFINITE
  1526. )
  1527. {
  1528. if ( X_INFINITE < 0 )
  1529. {
  1530. if ( Y_INFINITE < 0 )
  1531. {
  1532. return FALSE ;
  1533. }
  1534. else if ( Y_INFINITE == 0 )
  1535. {
  1536. return TRUE ;
  1537. }
  1538. else
  1539. {
  1540. return TRUE ;
  1541. }
  1542. }
  1543. else if ( X_INFINITE == 0 )
  1544. {
  1545. if ( Y_INFINITE < 0 )
  1546. {
  1547. return FALSE ;
  1548. }
  1549. else if ( Y_INFINITE == 0 )
  1550. {
  1551. return X < Y ;
  1552. }
  1553. else
  1554. {
  1555. return TRUE ;
  1556. }
  1557. }
  1558. else
  1559. {
  1560. return FALSE ;
  1561. }
  1562. }
  1563. /******************************************************************************
  1564. *
  1565. * Name:
  1566. *
  1567. *
  1568. * Description:
  1569. *
  1570. *
  1571. *****************************************************************************/
  1572. BOOL CompareSignedIntegerLessOrEqual (
  1573. LONG X ,
  1574. LONG X_INFINITE ,
  1575. LONG Y ,
  1576. LONG Y_INFINITE
  1577. )
  1578. {
  1579. if ( X_INFINITE < 0 )
  1580. {
  1581. if ( Y_INFINITE < 0 )
  1582. {
  1583. return TRUE ;
  1584. }
  1585. else if ( Y_INFINITE == 0 )
  1586. {
  1587. return TRUE ;
  1588. }
  1589. else
  1590. {
  1591. return TRUE ;
  1592. }
  1593. }
  1594. else if ( X_INFINITE == 0 )
  1595. {
  1596. if ( Y_INFINITE < 0 )
  1597. {
  1598. return FALSE ;
  1599. }
  1600. else if ( Y_INFINITE == 0 )
  1601. {
  1602. return X <= Y ;
  1603. }
  1604. else
  1605. {
  1606. return TRUE ;
  1607. }
  1608. }
  1609. else
  1610. {
  1611. if ( Y_INFINITE > 0 )
  1612. {
  1613. return TRUE ;
  1614. }
  1615. else
  1616. {
  1617. return FALSE ;
  1618. }
  1619. }
  1620. }
  1621. /******************************************************************************
  1622. *
  1623. * Name:
  1624. *
  1625. *
  1626. * Description:
  1627. *
  1628. *
  1629. *****************************************************************************/
  1630. BOOL CompareSignedIntegerGreater (
  1631. LONG X ,
  1632. LONG X_INFINITE ,
  1633. LONG Y ,
  1634. LONG Y_INFINITE
  1635. )
  1636. {
  1637. if ( X_INFINITE < 0 )
  1638. {
  1639. return FALSE ;
  1640. }
  1641. else if ( X_INFINITE == 0 )
  1642. {
  1643. if ( Y_INFINITE < 0 )
  1644. {
  1645. return TRUE ;
  1646. }
  1647. else if ( Y_INFINITE == 0 )
  1648. {
  1649. return X > Y ;
  1650. }
  1651. else
  1652. {
  1653. return FALSE ;
  1654. }
  1655. }
  1656. else
  1657. {
  1658. if ( Y_INFINITE < 0 )
  1659. {
  1660. return TRUE ;
  1661. }
  1662. else if ( Y_INFINITE == 0 )
  1663. {
  1664. return TRUE ;
  1665. }
  1666. else
  1667. {
  1668. return FALSE ;
  1669. }
  1670. }
  1671. }
  1672. /******************************************************************************
  1673. *
  1674. * Name:
  1675. *
  1676. *
  1677. * Description:
  1678. *
  1679. *
  1680. *****************************************************************************/
  1681. BOOL CompareSignedIntegerEqual (
  1682. LONG X ,
  1683. LONG X_INFINITE ,
  1684. LONG Y ,
  1685. LONG Y_INFINITE
  1686. )
  1687. {
  1688. if ( X_INFINITE < 0 && Y_INFINITE < 0 )
  1689. {
  1690. return TRUE ;
  1691. }
  1692. else if ( X_INFINITE == 0 && Y_INFINITE == 0 )
  1693. {
  1694. return X == Y ;
  1695. }
  1696. else if ( X_INFINITE > 0 && Y_INFINITE > 0 )
  1697. {
  1698. return TRUE ;
  1699. }
  1700. else
  1701. {
  1702. return FALSE ;
  1703. }
  1704. }
  1705. /******************************************************************************
  1706. *
  1707. * Name:
  1708. *
  1709. *
  1710. * Description:
  1711. *
  1712. *
  1713. *****************************************************************************/
  1714. BOOL CompareStringLess (
  1715. BSTR X ,
  1716. LONG X_INFINITE ,
  1717. BSTR Y ,
  1718. LONG Y_INFINITE
  1719. )
  1720. {
  1721. if ( X_INFINITE < 0 )
  1722. {
  1723. if ( Y_INFINITE < 0 )
  1724. {
  1725. return FALSE ;
  1726. }
  1727. else if ( Y_INFINITE == 0 )
  1728. {
  1729. return TRUE ;
  1730. }
  1731. else
  1732. {
  1733. return TRUE ;
  1734. }
  1735. }
  1736. else if ( X_INFINITE == 0 )
  1737. {
  1738. if ( Y_INFINITE < 0 )
  1739. {
  1740. return FALSE ;
  1741. }
  1742. else if ( Y_INFINITE == 0 )
  1743. {
  1744. return wcscmp ( X , Y ) < 0 ;
  1745. }
  1746. else
  1747. {
  1748. return TRUE ;
  1749. }
  1750. }
  1751. else
  1752. {
  1753. return FALSE ;
  1754. }
  1755. }
  1756. /******************************************************************************
  1757. *
  1758. * Name:
  1759. *
  1760. *
  1761. * Description:
  1762. *
  1763. *
  1764. *****************************************************************************/
  1765. BOOL CompareStringLessOrEqual (
  1766. BSTR X ,
  1767. LONG X_INFINITE ,
  1768. BSTR Y ,
  1769. LONG Y_INFINITE
  1770. )
  1771. {
  1772. if ( X_INFINITE < 0 )
  1773. {
  1774. if ( Y_INFINITE < 0 )
  1775. {
  1776. return TRUE ;
  1777. }
  1778. else if ( Y_INFINITE == 0 )
  1779. {
  1780. return TRUE ;
  1781. }
  1782. else
  1783. {
  1784. return TRUE ;
  1785. }
  1786. }
  1787. else if ( X_INFINITE == 0 )
  1788. {
  1789. if ( Y_INFINITE < 0 )
  1790. {
  1791. return FALSE ;
  1792. }
  1793. else if ( Y_INFINITE == 0 )
  1794. {
  1795. return wcscmp ( X , Y ) <= 0 ;
  1796. }
  1797. else
  1798. {
  1799. return TRUE ;
  1800. }
  1801. }
  1802. else
  1803. {
  1804. if ( Y_INFINITE > 0 )
  1805. {
  1806. return TRUE ;
  1807. }
  1808. else
  1809. {
  1810. return FALSE ;
  1811. }
  1812. }
  1813. }
  1814. /******************************************************************************
  1815. *
  1816. * Name:
  1817. *
  1818. *
  1819. * Description:
  1820. *
  1821. *
  1822. *****************************************************************************/
  1823. BOOL CompareStringGreater (
  1824. BSTR X ,
  1825. LONG X_INFINITE ,
  1826. BSTR Y ,
  1827. LONG Y_INFINITE
  1828. )
  1829. {
  1830. if ( X_INFINITE < 0 )
  1831. {
  1832. return FALSE ;
  1833. }
  1834. else if ( X_INFINITE == 0 )
  1835. {
  1836. if ( Y_INFINITE < 0 )
  1837. {
  1838. return TRUE ;
  1839. }
  1840. else if ( Y_INFINITE == 0 )
  1841. {
  1842. return wcscmp ( X , Y ) > 0 ;
  1843. }
  1844. else
  1845. {
  1846. return FALSE ;
  1847. }
  1848. }
  1849. else
  1850. {
  1851. if ( Y_INFINITE < 0 )
  1852. {
  1853. return TRUE ;
  1854. }
  1855. else if ( Y_INFINITE == 0 )
  1856. {
  1857. return TRUE ;
  1858. }
  1859. else
  1860. {
  1861. return FALSE ;
  1862. }
  1863. }
  1864. }
  1865. /******************************************************************************
  1866. *
  1867. * Name:
  1868. *
  1869. *
  1870. * Description:
  1871. *
  1872. *
  1873. *****************************************************************************/
  1874. BOOL CompareStringEqual (
  1875. BSTR X ,
  1876. LONG X_INFINITE ,
  1877. BSTR Y ,
  1878. LONG Y_INFINITE
  1879. )
  1880. {
  1881. if ( X_INFINITE < 0 && Y_INFINITE < 0 )
  1882. {
  1883. return TRUE ;
  1884. }
  1885. else if ( X_INFINITE == 0 && Y_INFINITE == 0 )
  1886. {
  1887. return wcscmp ( X , Y ) == 0 ;
  1888. }
  1889. else if ( X_INFINITE > 0 && Y_INFINITE > 0 )
  1890. {
  1891. return TRUE ;
  1892. }
  1893. else
  1894. {
  1895. return FALSE ;
  1896. }
  1897. }
  1898. /******************************************************************************
  1899. *
  1900. * Name:
  1901. *
  1902. *
  1903. * Description:
  1904. *
  1905. *
  1906. *****************************************************************************/
  1907. BOOL CompareLessOrEqualRangeNode (
  1908. WmiRangeNode *a_LeftRange ,
  1909. WmiRangeNode *a_RightRange
  1910. )
  1911. {
  1912. LONG t_State = 0 ;
  1913. if ( ( a_LeftRange->GetType () == TypeId_WmiStringRangeNode ) && ( a_RightRange->GetType () == TypeId_WmiStringRangeNode ) )
  1914. {
  1915. WmiStringRangeNode *t_LeftString = ( WmiStringRangeNode * ) a_LeftRange ;
  1916. WmiStringRangeNode *t_RightString = ( WmiStringRangeNode * ) a_RightRange ;
  1917. t_State = CompareStringLessOrEqual (
  1918. t_LeftString->LowerBound () ,
  1919. t_LeftString->InfiniteLowerBound () ? -1 : 0 ,
  1920. t_RightString->LowerBound () ,
  1921. t_RightString->InfiniteLowerBound () ? -1 : 0
  1922. ) ;
  1923. }
  1924. else if ( ( a_LeftRange->GetType () == TypeId_WmiSignedIntegerRangeNode ) && ( a_RightRange->GetType () == TypeId_WmiSignedIntegerRangeNode ) )
  1925. {
  1926. WmiSignedIntegerRangeNode *t_LeftInteger = ( WmiSignedIntegerRangeNode * ) a_LeftRange ;
  1927. WmiSignedIntegerRangeNode *t_RightInteger = ( WmiSignedIntegerRangeNode * ) a_RightRange ;
  1928. t_State = CompareSignedIntegerLessOrEqual (
  1929. t_LeftInteger->LowerBound () ,
  1930. t_LeftInteger->InfiniteLowerBound () ? -1 : 0 ,
  1931. t_RightInteger->LowerBound () ,
  1932. t_RightInteger->InfiniteLowerBound () ? -1 : 0
  1933. ) ;
  1934. }
  1935. else if ( ( a_LeftRange->GetType () == TypeId_WmiUnsignedIntegerRangeNode ) && ( a_RightRange->GetType () == TypeId_WmiUnsignedIntegerRangeNode ) )
  1936. {
  1937. WmiUnsignedIntegerRangeNode *t_LeftInteger = ( WmiUnsignedIntegerRangeNode * ) a_LeftRange ;
  1938. WmiUnsignedIntegerRangeNode *t_RightInteger = ( WmiUnsignedIntegerRangeNode * ) a_RightRange ;
  1939. t_State = CompareUnsignedIntegerLessOrEqual (
  1940. t_LeftInteger->LowerBound () ,
  1941. t_LeftInteger->InfiniteLowerBound () ? -1 : 0 ,
  1942. t_RightInteger->LowerBound () ,
  1943. t_RightInteger->InfiniteLowerBound () ? -1 : 0
  1944. ) ;
  1945. }
  1946. else if ( ( a_LeftRange->GetType () == TypeId_WmiNullRangeNode ) && ( a_RightRange->GetType () == TypeId_WmiNullRangeNode ) )
  1947. {
  1948. t_State = TRUE ;
  1949. }
  1950. return t_State ;
  1951. }
  1952. template<typename T>
  1953. WmiTriState CheckValid(T *& node)
  1954. {
  1955. if ( node && node->IsValid())
  1956. {
  1957. return State_True;
  1958. }
  1959. else
  1960. {
  1961. delete node;
  1962. node = 0;
  1963. return State_Error;
  1964. };
  1965. }
  1966. /******************************************************************************
  1967. *
  1968. * Name:
  1969. *
  1970. *
  1971. * Description:
  1972. *
  1973. *
  1974. *****************************************************************************/
  1975. WmiTriState WmiUnsignedIntegerRangeNode :: GetIntersectingRange (
  1976. WmiUnsignedIntegerRangeNode &a_UnsignedInteger ,
  1977. WmiUnsignedIntegerRangeNode *&a_Intersection
  1978. )
  1979. {
  1980. WmiTriState t_Status = :: State_False ;
  1981. // A weak ( open ) relationship is ( < , > )
  1982. // A strong ( closed ) relationship is ( == , <= , >= )
  1983. a_Intersection = NULL ;
  1984. ULONG X_S = m_LowerBound ;
  1985. ULONG X_E = m_UpperBound ;
  1986. ULONG Y_S = a_UnsignedInteger.m_LowerBound ;
  1987. ULONG Y_E = a_UnsignedInteger.m_UpperBound ;
  1988. BOOL X_S_CLOSED = m_LowerBoundClosed ;
  1989. BOOL X_E_CLOSED = m_UpperBoundClosed ;
  1990. BOOL Y_S_CLOSED = a_UnsignedInteger.m_LowerBoundClosed ;
  1991. BOOL Y_E_CLOSED = a_UnsignedInteger.m_UpperBoundClosed ;
  1992. BOOL X_S_INFINITE = m_InfiniteLowerBound ;
  1993. BOOL X_E_INFINITE = m_InfiniteUpperBound ;
  1994. BOOL Y_S_INFINITE = a_UnsignedInteger.m_InfiniteLowerBound ;
  1995. BOOL Y_E_INFINITE = a_UnsignedInteger.m_InfiniteUpperBound ;
  1996. if ( CompareUnsignedIntegerLess ( X_S , X_S_INFINITE ? - 1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S < Y_S )
  1997. {
  1998. if ( CompareUnsignedIntegerLess ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S < X_E )
  1999. {
  2000. if ( CompareUnsignedIntegerLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  2001. {
  2002. // Order ( X_S < Y_S < X_E < Y_E )
  2003. // Range ( Y_S , X_E )
  2004. a_Intersection = new WmiUnsignedIntegerRangeNode (
  2005. m_PropertyName ,
  2006. m_Index ,
  2007. Y_S_INFINITE ,
  2008. X_E_INFINITE ,
  2009. Y_S_CLOSED , // Relationship is as strong as ordering
  2010. X_E_CLOSED , // Relationship is as strong as ordering
  2011. Y_S ,
  2012. X_E ,
  2013. NULL ,
  2014. NULL
  2015. ) ;
  2016. t_Status = CheckValid(a_Intersection);
  2017. }
  2018. else if ( CompareUnsignedIntegerEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  2019. {
  2020. // Order ( X_S < Y_S < X_E == Y_E )
  2021. // Range ( Y_S , X_E )
  2022. a_Intersection = new WmiUnsignedIntegerRangeNode (
  2023. m_PropertyName ,
  2024. m_Index ,
  2025. Y_S_INFINITE ,
  2026. X_E_INFINITE ,
  2027. Y_S_CLOSED , // Relationship is as strong as ordering
  2028. X_E_CLOSED && Y_E_CLOSED , // Check for weak relationship ( < , > )
  2029. Y_S ,
  2030. X_E ,
  2031. NULL ,
  2032. NULL
  2033. ) ;
  2034. t_Status = CheckValid(a_Intersection);
  2035. }
  2036. else if ( CompareUnsignedIntegerGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  2037. {
  2038. // Order ( X_S < Y_S < Y_E < X_E )
  2039. // Range ( Y_S , Y_E )
  2040. a_Intersection = new WmiUnsignedIntegerRangeNode (
  2041. m_PropertyName ,
  2042. m_Index ,
  2043. Y_S_INFINITE ,
  2044. Y_E_INFINITE ,
  2045. Y_S_CLOSED , // Relationship is as strong as ordering
  2046. Y_E_CLOSED , // Relationship is as strong as ordering
  2047. Y_S ,
  2048. Y_E ,
  2049. NULL ,
  2050. NULL
  2051. ) ;
  2052. t_Status = CheckValid(a_Intersection);
  2053. }
  2054. }
  2055. else if ( CompareUnsignedIntegerEqual ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S == X_E ), Start of Y and End Of X overlap
  2056. {
  2057. if ( Y_S_CLOSED && X_E_CLOSED )
  2058. {
  2059. // Order ( X_S < Y_S == X_E )
  2060. // Range ( Y_S , X_E )
  2061. a_Intersection = new WmiUnsignedIntegerRangeNode (
  2062. m_PropertyName ,
  2063. m_Index ,
  2064. FALSE ,
  2065. FALSE ,
  2066. TRUE ,
  2067. TRUE ,
  2068. Y_S ,
  2069. Y_S ,
  2070. NULL ,
  2071. NULL
  2072. ) ;
  2073. t_Status = CheckValid(a_Intersection);
  2074. }
  2075. else
  2076. {
  2077. // Empty set
  2078. }
  2079. }
  2080. else if ( CompareUnsignedIntegerGreater ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S > X_E )
  2081. {
  2082. // Order ( X_S < Y_S , X_E < Y_S )
  2083. // Non overlapping regions therefore empty set
  2084. }
  2085. }
  2086. else if ( CompareUnsignedIntegerEqual ( X_S , X_S_INFINITE ? -1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S == Y_S )
  2087. {
  2088. if ( CompareUnsignedIntegerLess ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S < X_E )
  2089. {
  2090. if ( CompareUnsignedIntegerLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  2091. {
  2092. // Order ( X_S == Y_S < X_E < Y_E )
  2093. // Range ( Y_S , X_E )
  2094. a_Intersection = new WmiUnsignedIntegerRangeNode (
  2095. m_PropertyName ,
  2096. m_Index ,
  2097. Y_S_INFINITE ,
  2098. Y_E_INFINITE ,
  2099. X_S_CLOSED && Y_S_CLOSED , // Check for weak relationship ( < , > )
  2100. X_E_CLOSED , // Relationship is as strong as ordering
  2101. Y_S ,
  2102. X_E ,
  2103. NULL ,
  2104. NULL
  2105. ) ;
  2106. t_Status = CheckValid(a_Intersection);
  2107. }
  2108. else if ( CompareUnsignedIntegerEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  2109. {
  2110. // Order ( X_S == Y_S < X_E == Y_E )
  2111. // Range ( X_S , X_E )
  2112. a_Intersection = new WmiUnsignedIntegerRangeNode (
  2113. m_PropertyName ,
  2114. m_Index ,
  2115. Y_S_INFINITE ,
  2116. Y_E_INFINITE ,
  2117. X_S_CLOSED && Y_S_CLOSED , // Check for weak relationship ( < , > )
  2118. Y_E_CLOSED && X_E_CLOSED , // Check for weak relationship ( < , > )
  2119. X_S ,
  2120. X_E ,
  2121. NULL ,
  2122. NULL
  2123. ) ;
  2124. t_Status = CheckValid(a_Intersection);
  2125. }
  2126. else if ( CompareUnsignedIntegerGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  2127. {
  2128. // Order ( X_S == Y_S < Y_E < X_E )
  2129. // Range ( X_S , Y_E )
  2130. a_Intersection = new WmiUnsignedIntegerRangeNode (
  2131. m_PropertyName ,
  2132. m_Index ,
  2133. Y_S_INFINITE ,
  2134. Y_E_INFINITE ,
  2135. X_S_CLOSED && Y_S_CLOSED , // Check for weak relationship ( < , > )
  2136. Y_E_CLOSED , // Relationship is as strong as ordering
  2137. X_S ,
  2138. Y_E ,
  2139. NULL ,
  2140. NULL
  2141. ) ;
  2142. t_Status = CheckValid(a_Intersection);
  2143. }
  2144. }
  2145. else if ( CompareUnsignedIntegerEqual ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S == X_E ), Start of Y and End Of X overlap
  2146. {
  2147. if ( Y_S_CLOSED && X_E_CLOSED )
  2148. {
  2149. // Order ( X_S == Y_S == X_E )
  2150. // Range ( Y_S , Y_E )
  2151. a_Intersection = new WmiUnsignedIntegerRangeNode (
  2152. m_PropertyName ,
  2153. m_Index ,
  2154. FALSE ,
  2155. FALSE ,
  2156. TRUE ,
  2157. TRUE ,
  2158. Y_S ,
  2159. Y_S ,
  2160. NULL ,
  2161. NULL
  2162. ) ;
  2163. t_Status = CheckValid(a_Intersection);
  2164. }
  2165. else
  2166. {
  2167. // Empty set
  2168. }
  2169. }
  2170. else if ( CompareUnsignedIntegerGreater ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S > X_E )
  2171. {
  2172. _DBG_ASSERT(FALSE);
  2173. }
  2174. }
  2175. else if ( CompareUnsignedIntegerGreater ( X_S , X_S_INFINITE ? -1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S > Y_S )
  2176. {
  2177. if ( CompareUnsignedIntegerLess ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S < Y_E )
  2178. {
  2179. if ( CompareUnsignedIntegerLess ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E < X_E )
  2180. {
  2181. // Order ( Y_S < X_S < Y_E < X_E )
  2182. // Range ( X_S , Y_E )
  2183. a_Intersection = new WmiUnsignedIntegerRangeNode (
  2184. m_PropertyName ,
  2185. m_Index ,
  2186. X_S_INFINITE ,
  2187. Y_E_INFINITE ,
  2188. X_S_CLOSED , // Relationship is as strong as ordering
  2189. Y_E_CLOSED , // Relationship is as strong as ordering
  2190. X_S ,
  2191. Y_E ,
  2192. NULL ,
  2193. NULL
  2194. ) ;
  2195. t_Status = CheckValid(a_Intersection);
  2196. }
  2197. else if ( CompareUnsignedIntegerEqual ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E == X_E )
  2198. {
  2199. // Order ( Y_S < X_S < Y_E == X_E )
  2200. // Range ( X_S , Y_E )
  2201. a_Intersection = new WmiUnsignedIntegerRangeNode (
  2202. m_PropertyName ,
  2203. m_Index ,
  2204. X_S_INFINITE ,
  2205. Y_E_INFINITE ,
  2206. X_S_CLOSED , // Relationship is as strong as ordering
  2207. Y_E_CLOSED && X_E_CLOSED , // Check for weak relationship ( < , > )
  2208. X_S ,
  2209. Y_E ,
  2210. NULL ,
  2211. NULL
  2212. ) ;
  2213. t_Status = CheckValid(a_Intersection);
  2214. }
  2215. else if ( CompareUnsignedIntegerGreater ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E > X_E )
  2216. {
  2217. // Order ( Y_S < X_S < X_E < Y_E )
  2218. // Range ( X_S , X_E )
  2219. a_Intersection = new WmiUnsignedIntegerRangeNode (
  2220. m_PropertyName ,
  2221. m_Index ,
  2222. X_S_INFINITE ,
  2223. X_E_INFINITE ,
  2224. X_S_CLOSED , // Relationship is as strong as ordering
  2225. X_E_CLOSED , // Relationship is as strong as ordering
  2226. X_S ,
  2227. X_E ,
  2228. NULL ,
  2229. NULL
  2230. ) ;
  2231. t_Status = CheckValid(a_Intersection);
  2232. }
  2233. }
  2234. else if ( CompareUnsignedIntegerEqual ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S == Y_E ), Start of X and End Of Y overlap
  2235. {
  2236. if ( X_S_CLOSED && Y_E_CLOSED )
  2237. {
  2238. // Order ( Y_S < X_S == X_E )
  2239. // Range ( X_S , Y_E )
  2240. a_Intersection = new WmiUnsignedIntegerRangeNode (
  2241. m_PropertyName ,
  2242. m_Index ,
  2243. FALSE ,
  2244. FALSE ,
  2245. TRUE ,
  2246. TRUE ,
  2247. X_S ,
  2248. X_S ,
  2249. NULL ,
  2250. NULL
  2251. ) ;
  2252. t_Status = CheckValid(a_Intersection);
  2253. }
  2254. else
  2255. {
  2256. // Empty set
  2257. }
  2258. }
  2259. else if ( CompareUnsignedIntegerGreater ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S > Y_E )
  2260. {
  2261. // Empty
  2262. }
  2263. }
  2264. return t_Status ;
  2265. }
  2266. /******************************************************************************
  2267. *
  2268. * Name:
  2269. *
  2270. *
  2271. * Description:
  2272. *
  2273. *
  2274. *****************************************************************************/
  2275. WmiTriState WmiSignedIntegerRangeNode :: GetIntersectingRange (
  2276. WmiSignedIntegerRangeNode &a_SignedInteger ,
  2277. WmiSignedIntegerRangeNode *&a_Intersection
  2278. )
  2279. {
  2280. WmiTriState t_Status = :: State_False ;
  2281. // A weak ( open ) relationship is ( < , > )
  2282. // A strong ( closed ) relationship is ( == , <= , >= )
  2283. a_Intersection = NULL ;
  2284. LONG X_S = m_LowerBound ;
  2285. LONG X_E = m_UpperBound ;
  2286. LONG Y_S = a_SignedInteger.m_LowerBound ;
  2287. LONG Y_E = a_SignedInteger.m_UpperBound ;
  2288. BOOL X_S_CLOSED = m_LowerBoundClosed ;
  2289. BOOL X_E_CLOSED = m_UpperBoundClosed ;
  2290. BOOL Y_S_CLOSED = a_SignedInteger.m_LowerBoundClosed ;
  2291. BOOL Y_E_CLOSED = a_SignedInteger.m_UpperBoundClosed ;
  2292. BOOL X_S_INFINITE = m_InfiniteLowerBound ;
  2293. BOOL X_E_INFINITE = m_InfiniteUpperBound ;
  2294. BOOL Y_S_INFINITE = a_SignedInteger.m_InfiniteLowerBound ;
  2295. BOOL Y_E_INFINITE = a_SignedInteger.m_InfiniteUpperBound ;
  2296. if ( CompareSignedIntegerLess ( X_S , X_S_INFINITE ? - 1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S < Y_S )
  2297. {
  2298. if ( CompareSignedIntegerLess ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S < X_E )
  2299. {
  2300. if ( CompareSignedIntegerLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  2301. {
  2302. // Order ( X_S < Y_S < X_E < Y_E )
  2303. // Range ( Y_S , X_E )
  2304. a_Intersection = new WmiSignedIntegerRangeNode (
  2305. m_PropertyName ,
  2306. m_Index ,
  2307. Y_S_INFINITE ,
  2308. X_E_INFINITE ,
  2309. Y_S_CLOSED , // Relationship is as strong as ordering
  2310. X_E_CLOSED , // Relationship is as strong as ordering
  2311. Y_S ,
  2312. X_E ,
  2313. NULL ,
  2314. NULL
  2315. ) ;
  2316. t_Status = CheckValid(a_Intersection);
  2317. }
  2318. else if ( CompareSignedIntegerEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  2319. {
  2320. // Order ( X_S < Y_S < X_E == Y_E )
  2321. // Range ( Y_S , X_E )
  2322. a_Intersection = new WmiSignedIntegerRangeNode (
  2323. m_PropertyName ,
  2324. m_Index ,
  2325. Y_S_INFINITE ,
  2326. X_E_INFINITE ,
  2327. Y_S_CLOSED , // Relationship is as strong as ordering
  2328. X_E_CLOSED && Y_E_CLOSED , // Check for weak relationship ( < , > )
  2329. Y_S ,
  2330. X_E ,
  2331. NULL ,
  2332. NULL
  2333. ) ;
  2334. t_Status = CheckValid(a_Intersection);
  2335. }
  2336. else if ( CompareSignedIntegerGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  2337. {
  2338. // Order ( X_S < Y_S < Y_E < X_E )
  2339. // Range ( Y_S , Y_E )
  2340. a_Intersection = new WmiSignedIntegerRangeNode (
  2341. m_PropertyName ,
  2342. m_Index ,
  2343. Y_S_INFINITE ,
  2344. Y_E_INFINITE ,
  2345. Y_S_CLOSED , // Relationship is as strong as ordering
  2346. Y_E_CLOSED , // Relationship is as strong as ordering
  2347. Y_S ,
  2348. Y_E ,
  2349. NULL ,
  2350. NULL
  2351. ) ;
  2352. t_Status = CheckValid(a_Intersection);
  2353. }
  2354. }
  2355. else if ( CompareSignedIntegerEqual ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S == X_E ), Start of Y and End Of X overlap
  2356. {
  2357. if ( Y_S_CLOSED && X_E_CLOSED )
  2358. {
  2359. // Order ( X_S < Y_S == X_E )
  2360. // Range ( Y_S , X_E )
  2361. a_Intersection = new WmiSignedIntegerRangeNode (
  2362. m_PropertyName ,
  2363. m_Index ,
  2364. FALSE ,
  2365. FALSE ,
  2366. TRUE ,
  2367. TRUE ,
  2368. Y_S ,
  2369. Y_S ,
  2370. NULL ,
  2371. NULL
  2372. ) ;
  2373. t_Status = CheckValid(a_Intersection);
  2374. }
  2375. else
  2376. {
  2377. // Empty set
  2378. }
  2379. }
  2380. else if ( CompareSignedIntegerGreater ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S > X_E )
  2381. {
  2382. // Order ( X_S < Y_S , X_E < Y_S )
  2383. // Non overlapping regions therefore empty set
  2384. }
  2385. }
  2386. else if ( CompareSignedIntegerEqual ( X_S , X_S_INFINITE ? -1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S == Y_S )
  2387. {
  2388. if ( CompareSignedIntegerLess ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S < X_E )
  2389. {
  2390. if ( CompareSignedIntegerLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  2391. {
  2392. // Order ( X_S == Y_S < X_E < Y_E )
  2393. // Range ( Y_S , X_E )
  2394. a_Intersection = new WmiSignedIntegerRangeNode (
  2395. m_PropertyName ,
  2396. m_Index ,
  2397. Y_S_INFINITE ,
  2398. Y_E_INFINITE ,
  2399. X_S_CLOSED && Y_S_CLOSED , // Check for weak relationship ( < , > )
  2400. X_E_CLOSED , // Relationship is as strong as ordering
  2401. Y_S ,
  2402. X_E ,
  2403. NULL ,
  2404. NULL
  2405. ) ;
  2406. t_Status = CheckValid(a_Intersection);
  2407. }
  2408. else if ( CompareSignedIntegerEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  2409. {
  2410. // Order ( X_S == Y_S < X_E == Y_E )
  2411. // Range ( X_S , X_E )
  2412. a_Intersection = new WmiSignedIntegerRangeNode (
  2413. m_PropertyName ,
  2414. m_Index ,
  2415. Y_S_INFINITE ,
  2416. Y_E_INFINITE ,
  2417. X_S_CLOSED && Y_S_CLOSED , // Check for weak relationship ( < , > )
  2418. Y_E_CLOSED && X_E_CLOSED , // Check for weak relationship ( < , > )
  2419. X_S ,
  2420. X_E ,
  2421. NULL ,
  2422. NULL
  2423. ) ;
  2424. t_Status = CheckValid(a_Intersection);
  2425. }
  2426. else if ( CompareSignedIntegerGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  2427. {
  2428. // Order ( X_S == Y_S < Y_E < X_E )
  2429. // Range ( X_S , Y_E )
  2430. a_Intersection = new WmiSignedIntegerRangeNode (
  2431. m_PropertyName ,
  2432. m_Index ,
  2433. Y_S_INFINITE ,
  2434. Y_E_INFINITE ,
  2435. X_S_CLOSED && Y_S_CLOSED , // Check for weak relationship ( < , > )
  2436. Y_E_CLOSED , // Relationship is as strong as ordering
  2437. X_S ,
  2438. Y_E ,
  2439. NULL ,
  2440. NULL
  2441. ) ;
  2442. t_Status = CheckValid(a_Intersection);
  2443. }
  2444. }
  2445. else if ( CompareSignedIntegerEqual ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S == X_E ), Start of Y and End Of X overlap
  2446. {
  2447. if ( Y_S_CLOSED && X_E_CLOSED )
  2448. {
  2449. // Order ( X_S == Y_S == X_E )
  2450. // Range ( Y_S , Y_E )
  2451. a_Intersection = new WmiSignedIntegerRangeNode (
  2452. m_PropertyName ,
  2453. m_Index ,
  2454. FALSE ,
  2455. FALSE ,
  2456. TRUE ,
  2457. TRUE ,
  2458. Y_S ,
  2459. Y_S ,
  2460. NULL ,
  2461. NULL
  2462. ) ;
  2463. t_Status = CheckValid(a_Intersection);
  2464. }
  2465. else
  2466. {
  2467. // Empty set
  2468. }
  2469. }
  2470. else if ( CompareSignedIntegerGreater ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S > Y_E )
  2471. {
  2472. _DBG_ASSERT(FALSE);
  2473. }
  2474. }
  2475. else if ( CompareSignedIntegerGreater ( X_S , X_S_INFINITE ? -1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S > Y_S )
  2476. {
  2477. if ( CompareSignedIntegerLess ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S < Y_E )
  2478. {
  2479. if ( CompareSignedIntegerLess ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E < X_E )
  2480. {
  2481. // Order ( Y_S < X_S < Y_E < X_E )
  2482. // Range ( X_S , Y_E )
  2483. a_Intersection = new WmiSignedIntegerRangeNode (
  2484. m_PropertyName ,
  2485. m_Index ,
  2486. X_S_INFINITE ,
  2487. Y_E_INFINITE ,
  2488. X_S_CLOSED , // Relationship is as strong as ordering
  2489. Y_E_CLOSED , // Relationship is as strong as ordering
  2490. X_S ,
  2491. Y_E ,
  2492. NULL ,
  2493. NULL
  2494. ) ;
  2495. t_Status = CheckValid(a_Intersection);
  2496. }
  2497. else if ( CompareSignedIntegerEqual ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E == X_E )
  2498. {
  2499. // Order ( Y_S < X_S < Y_E == X_E )
  2500. // Range ( X_S , Y_E )
  2501. a_Intersection = new WmiSignedIntegerRangeNode (
  2502. m_PropertyName ,
  2503. m_Index ,
  2504. X_S_INFINITE ,
  2505. Y_E_INFINITE ,
  2506. X_S_CLOSED , // Relationship is as strong as ordering
  2507. Y_E_CLOSED && X_E_CLOSED , // Check for weak relationship ( < , > )
  2508. X_S ,
  2509. Y_E ,
  2510. NULL ,
  2511. NULL
  2512. ) ;
  2513. t_Status = CheckValid(a_Intersection);
  2514. }
  2515. else if ( CompareSignedIntegerGreater ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E > X_E )
  2516. {
  2517. // Order ( Y_S < X_S < X_E < Y_E )
  2518. // Range ( X_S , X_E )
  2519. a_Intersection = new WmiSignedIntegerRangeNode (
  2520. m_PropertyName ,
  2521. m_Index ,
  2522. X_S_INFINITE ,
  2523. X_E_INFINITE ,
  2524. X_S_CLOSED , // Relationship is as strong as ordering
  2525. X_E_CLOSED , // Relationship is as strong as ordering
  2526. X_S ,
  2527. X_E ,
  2528. NULL ,
  2529. NULL
  2530. ) ;
  2531. t_Status = CheckValid(a_Intersection);
  2532. }
  2533. }
  2534. else if ( CompareSignedIntegerEqual ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S == Y_E ), Start of X and End Of Y overlap
  2535. {
  2536. if ( X_S_CLOSED && Y_E_CLOSED )
  2537. {
  2538. // Order ( Y_S < X_S == X_E )
  2539. // Range ( X_S , Y_E )
  2540. a_Intersection = new WmiSignedIntegerRangeNode (
  2541. m_PropertyName ,
  2542. m_Index ,
  2543. FALSE ,
  2544. FALSE ,
  2545. TRUE ,
  2546. TRUE ,
  2547. X_S ,
  2548. X_S ,
  2549. NULL ,
  2550. NULL
  2551. ) ;
  2552. t_Status = CheckValid(a_Intersection);
  2553. }
  2554. else
  2555. {
  2556. // Empty set
  2557. }
  2558. }
  2559. else if ( CompareSignedIntegerGreater ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S > Y_E )
  2560. {
  2561. // Empty
  2562. }
  2563. }
  2564. return t_Status ;
  2565. }
  2566. /******************************************************************************
  2567. *
  2568. * Name:
  2569. *
  2570. *
  2571. * Description:
  2572. *
  2573. *
  2574. *****************************************************************************/
  2575. WmiTriState WmiStringRangeNode :: GetIntersectingRange (
  2576. WmiStringRangeNode &a_String ,
  2577. WmiStringRangeNode *&a_Intersection
  2578. )
  2579. {
  2580. WmiTriState t_Status = :: State_False ;
  2581. // A weak ( open ) relationship is ( < , > )
  2582. // A strong ( closed ) relationship is ( == , <= , >= )
  2583. a_Intersection = NULL ;
  2584. BSTR X_S = m_LowerBound ;
  2585. BSTR X_E = m_UpperBound ;
  2586. BSTR Y_S = a_String.m_LowerBound ;
  2587. BSTR Y_E = a_String.m_UpperBound ;
  2588. BOOL X_S_CLOSED = m_LowerBoundClosed ;
  2589. BOOL X_E_CLOSED = m_UpperBoundClosed ;
  2590. BOOL Y_S_CLOSED = a_String.m_LowerBoundClosed ;
  2591. BOOL Y_E_CLOSED = a_String.m_UpperBoundClosed ;
  2592. BOOL X_S_INFINITE = m_InfiniteLowerBound ;
  2593. BOOL X_E_INFINITE = m_InfiniteUpperBound ;
  2594. BOOL Y_S_INFINITE = a_String.m_InfiniteLowerBound ;
  2595. BOOL Y_E_INFINITE = a_String.m_InfiniteUpperBound ;
  2596. if ( CompareStringLess ( X_S , X_S_INFINITE ? - 1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S < Y_S )
  2597. {
  2598. if ( CompareStringLess ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S < X_E )
  2599. {
  2600. if ( CompareStringLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  2601. {
  2602. // Order ( X_S < Y_S < X_E < Y_E )
  2603. // Range ( Y_S , X_E )
  2604. a_Intersection = new WmiStringRangeNode (
  2605. m_PropertyName ,
  2606. m_Index ,
  2607. Y_S_INFINITE ,
  2608. X_E_INFINITE ,
  2609. Y_S_CLOSED , // Relationship is as strong as ordering
  2610. X_E_CLOSED , // Relationship is as strong as ordering
  2611. Y_S ,
  2612. X_E ,
  2613. NULL ,
  2614. NULL
  2615. ) ;
  2616. t_Status = CheckValid(a_Intersection);
  2617. }
  2618. else if ( CompareStringEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  2619. {
  2620. // Order ( X_S < Y_S < X_E == Y_E )
  2621. // Range ( Y_S , X_E )
  2622. a_Intersection = new WmiStringRangeNode (
  2623. m_PropertyName ,
  2624. m_Index ,
  2625. Y_S_INFINITE ,
  2626. X_E_INFINITE ,
  2627. Y_S_CLOSED , // Relationship is as strong as ordering
  2628. X_E_CLOSED && Y_E_CLOSED , // Check for weak relationship ( < , > )
  2629. Y_S ,
  2630. X_E ,
  2631. NULL ,
  2632. NULL
  2633. ) ;
  2634. t_Status = CheckValid(a_Intersection);
  2635. }
  2636. else if ( CompareStringGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  2637. {
  2638. // Order ( X_S < Y_S < Y_E < X_E )
  2639. // Range ( Y_S , Y_E )
  2640. a_Intersection = new WmiStringRangeNode (
  2641. m_PropertyName ,
  2642. m_Index ,
  2643. Y_S_INFINITE ,
  2644. Y_E_INFINITE ,
  2645. Y_S_CLOSED , // Relationship is as strong as ordering
  2646. Y_E_CLOSED , // Relationship is as strong as ordering
  2647. Y_S ,
  2648. Y_E ,
  2649. NULL ,
  2650. NULL
  2651. ) ;
  2652. t_Status = CheckValid(a_Intersection);
  2653. }
  2654. }
  2655. else if ( CompareStringEqual ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S == X_E ), Start of Y and End Of X overlap
  2656. {
  2657. if ( Y_S_CLOSED && X_E_CLOSED )
  2658. {
  2659. // Order ( X_S < Y_S == X_E )
  2660. // Range ( Y_S , X_E )
  2661. a_Intersection = new WmiStringRangeNode (
  2662. m_PropertyName ,
  2663. m_Index ,
  2664. FALSE ,
  2665. FALSE ,
  2666. TRUE ,
  2667. TRUE ,
  2668. Y_S ,
  2669. Y_S ,
  2670. NULL ,
  2671. NULL
  2672. ) ;
  2673. t_Status = CheckValid(a_Intersection);
  2674. }
  2675. else
  2676. {
  2677. // Empty set
  2678. }
  2679. }
  2680. else if ( CompareStringGreater ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S > X_E )
  2681. {
  2682. // Order ( X_S < Y_S , X_E < Y_S )
  2683. // Non overlapping regions therefore empty set
  2684. }
  2685. }
  2686. else if ( CompareStringEqual ( X_S , X_S_INFINITE ? -1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S == Y_S )
  2687. {
  2688. if ( CompareStringLess ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S < X_E )
  2689. {
  2690. if ( CompareStringLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  2691. {
  2692. // Order ( X_S == Y_S < X_E < Y_E )
  2693. // Range ( Y_S , X_E )
  2694. a_Intersection = new WmiStringRangeNode (
  2695. m_PropertyName ,
  2696. m_Index ,
  2697. Y_S_INFINITE ,
  2698. Y_E_INFINITE ,
  2699. X_S_CLOSED && Y_S_CLOSED , // Check for weak relationship ( < , > )
  2700. X_E_CLOSED , // Relationship is as strong as ordering
  2701. Y_S ,
  2702. X_E ,
  2703. NULL ,
  2704. NULL
  2705. ) ;
  2706. t_Status = CheckValid(a_Intersection);
  2707. }
  2708. else if ( CompareStringEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  2709. {
  2710. // Order ( X_S == Y_S < X_E == Y_E )
  2711. // Range ( X_S , X_E )
  2712. a_Intersection = new WmiStringRangeNode (
  2713. m_PropertyName ,
  2714. m_Index ,
  2715. Y_S_INFINITE ,
  2716. Y_E_INFINITE ,
  2717. X_S_CLOSED && Y_S_CLOSED , // Check for weak relationship ( < , > )
  2718. Y_E_CLOSED && X_E_CLOSED , // Check for weak relationship ( < , > )
  2719. X_S ,
  2720. X_E ,
  2721. NULL ,
  2722. NULL
  2723. ) ;
  2724. t_Status = CheckValid(a_Intersection);
  2725. }
  2726. else if ( CompareStringGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  2727. {
  2728. // Order ( X_S == Y_S < Y_E < X_E )
  2729. // Range ( X_S , Y_E )
  2730. a_Intersection = new WmiStringRangeNode (
  2731. m_PropertyName ,
  2732. m_Index ,
  2733. Y_S_INFINITE ,
  2734. Y_E_INFINITE ,
  2735. X_S_CLOSED && Y_S_CLOSED , // Check for weak relationship ( < , > )
  2736. Y_E_CLOSED , // Relationship is as strong as ordering
  2737. X_S ,
  2738. Y_E ,
  2739. NULL ,
  2740. NULL
  2741. ) ;
  2742. t_Status = CheckValid(a_Intersection);
  2743. }
  2744. }
  2745. else if ( CompareStringEqual ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S == X_E ), Start of Y and End Of X overlap
  2746. {
  2747. if ( Y_S_CLOSED && X_E_CLOSED )
  2748. {
  2749. // Order ( X_S == Y_S == X_E )
  2750. // Range ( Y_S , Y_E )
  2751. a_Intersection = new WmiStringRangeNode (
  2752. m_PropertyName ,
  2753. m_Index ,
  2754. FALSE ,
  2755. FALSE ,
  2756. TRUE ,
  2757. TRUE ,
  2758. Y_S ,
  2759. Y_S ,
  2760. NULL ,
  2761. NULL
  2762. ) ;
  2763. t_Status = CheckValid(a_Intersection);
  2764. }
  2765. else
  2766. {
  2767. // Empty set
  2768. }
  2769. }
  2770. else if ( CompareStringGreater ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S > Y_E )
  2771. {
  2772. _DBG_ASSERT(FALSE);
  2773. }
  2774. }
  2775. else if ( CompareStringGreater ( X_S , X_S_INFINITE ? -1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S > Y_S )
  2776. {
  2777. if ( CompareStringLess ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S < Y_E )
  2778. {
  2779. if ( CompareStringLess ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E < X_E )
  2780. {
  2781. // Order ( Y_S < X_S < Y_E < X_E )
  2782. // Range ( X_S , Y_E )
  2783. a_Intersection = new WmiStringRangeNode (
  2784. m_PropertyName ,
  2785. m_Index ,
  2786. X_S_INFINITE ,
  2787. Y_E_INFINITE ,
  2788. X_S_CLOSED , // Relationship is as strong as ordering
  2789. Y_E_CLOSED , // Relationship is as strong as ordering
  2790. X_S ,
  2791. Y_E ,
  2792. NULL ,
  2793. NULL
  2794. ) ;
  2795. t_Status = CheckValid(a_Intersection);
  2796. }
  2797. else if ( CompareStringEqual ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E == X_E )
  2798. {
  2799. // Order ( Y_S < X_S < Y_E == X_E )
  2800. // Range ( X_S , Y_E )
  2801. a_Intersection = new WmiStringRangeNode (
  2802. m_PropertyName ,
  2803. m_Index ,
  2804. X_S_INFINITE ,
  2805. Y_E_INFINITE ,
  2806. X_S_CLOSED , // Relationship is as strong as ordering
  2807. Y_E_CLOSED && X_E_CLOSED , // Check for weak relationship ( < , > )
  2808. X_S ,
  2809. Y_E ,
  2810. NULL ,
  2811. NULL
  2812. ) ;
  2813. t_Status = CheckValid(a_Intersection);
  2814. }
  2815. else if ( CompareStringGreater ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E > X_E )
  2816. {
  2817. // Order ( Y_S < X_S < X_E < Y_E )
  2818. // Range ( X_S , X_E )
  2819. a_Intersection = new WmiStringRangeNode (
  2820. m_PropertyName ,
  2821. m_Index ,
  2822. X_S_INFINITE ,
  2823. X_E_INFINITE ,
  2824. X_S_CLOSED , // Relationship is as strong as ordering
  2825. X_E_CLOSED , // Relationship is as strong as ordering
  2826. X_S ,
  2827. X_E ,
  2828. NULL ,
  2829. NULL
  2830. ) ;
  2831. t_Status = CheckValid(a_Intersection);
  2832. }
  2833. }
  2834. else if ( CompareStringEqual ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S == Y_E ), Start of X and End Of Y overlap
  2835. {
  2836. if ( X_S_CLOSED && Y_E_CLOSED )
  2837. {
  2838. // Order ( Y_S < X_S == X_E )
  2839. // Range ( X_S , Y_E )
  2840. a_Intersection = new WmiStringRangeNode (
  2841. m_PropertyName ,
  2842. m_Index ,
  2843. FALSE ,
  2844. FALSE ,
  2845. TRUE ,
  2846. TRUE ,
  2847. X_S ,
  2848. X_S ,
  2849. NULL ,
  2850. NULL
  2851. ) ;
  2852. t_Status = CheckValid(a_Intersection);
  2853. }
  2854. else
  2855. {
  2856. // Empty set
  2857. }
  2858. }
  2859. else if ( CompareStringGreater ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S > Y_E )
  2860. {
  2861. // empty
  2862. }
  2863. }
  2864. return t_Status ;
  2865. }
  2866. /******************************************************************************
  2867. *
  2868. * Name:
  2869. *
  2870. *
  2871. * Description:
  2872. *
  2873. *
  2874. *****************************************************************************/
  2875. WmiTriState WmiSignedIntegerRangeNode :: GetOverlappingRange (
  2876. WmiSignedIntegerRangeNode &a_SignedInteger ,
  2877. WmiSignedIntegerRangeNode *&a_Overlap
  2878. )
  2879. {
  2880. WmiTriState t_Status = :: State_False ;
  2881. // A weak ( open ) relationship is ( < , > )
  2882. // A strong ( closed ) relationship is ( == , <= , >= )
  2883. a_Overlap = NULL ;
  2884. LONG X_S = m_LowerBound ;
  2885. LONG X_E = m_UpperBound ;
  2886. LONG Y_S = a_SignedInteger.m_LowerBound ;
  2887. LONG Y_E = a_SignedInteger.m_UpperBound ;
  2888. BOOL X_S_CLOSED = m_LowerBoundClosed ;
  2889. BOOL X_E_CLOSED = m_UpperBoundClosed ;
  2890. BOOL Y_S_CLOSED = a_SignedInteger.m_LowerBoundClosed ;
  2891. BOOL Y_E_CLOSED = a_SignedInteger.m_UpperBoundClosed ;
  2892. BOOL X_S_INFINITE = m_InfiniteLowerBound ;
  2893. BOOL X_E_INFINITE = m_InfiniteUpperBound ;
  2894. BOOL Y_S_INFINITE = a_SignedInteger.m_InfiniteLowerBound ;
  2895. BOOL Y_E_INFINITE = a_SignedInteger.m_InfiniteUpperBound ;
  2896. if ( CompareSignedIntegerLess ( X_S , X_S_INFINITE ? - 1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S < Y_S )
  2897. {
  2898. if ( CompareSignedIntegerLess ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S < X_E )
  2899. {
  2900. if ( CompareSignedIntegerLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  2901. {
  2902. // Order ( X_S < Y_S < X_E < Y_E )
  2903. // Range ( X_S , Y_E )
  2904. a_Overlap = new WmiSignedIntegerRangeNode (
  2905. m_PropertyName ,
  2906. m_Index ,
  2907. X_S_INFINITE ,
  2908. Y_E_INFINITE ,
  2909. X_S_CLOSED , // Relationship is as strong as ordering
  2910. Y_E_CLOSED , // Relationship is as strong as ordering
  2911. X_S ,
  2912. Y_E ,
  2913. NULL ,
  2914. NULL
  2915. ) ;
  2916. t_Status = CheckValid(a_Overlap);
  2917. }
  2918. else if ( CompareSignedIntegerEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  2919. {
  2920. // Order ( X_S < Y_S < X_E == Y_E )
  2921. // Range ( X_S , X_E )
  2922. a_Overlap = new WmiSignedIntegerRangeNode (
  2923. m_PropertyName ,
  2924. m_Index ,
  2925. X_S_INFINITE ,
  2926. X_E_INFINITE ,
  2927. X_S_CLOSED , // Relationship is as strong as ordering
  2928. X_E_CLOSED || Y_E_CLOSED , // Check for weak relationship ( < , > )
  2929. X_S ,
  2930. X_E ,
  2931. NULL ,
  2932. NULL
  2933. ) ;
  2934. t_Status = CheckValid(a_Overlap);
  2935. }
  2936. else if ( CompareSignedIntegerGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  2937. {
  2938. // Order ( X_S < Y_S < Y_E < X_E )
  2939. // Range ( X_S , X_E )
  2940. a_Overlap = new WmiSignedIntegerRangeNode (
  2941. m_PropertyName ,
  2942. m_Index ,
  2943. X_S_INFINITE ,
  2944. X_E_INFINITE ,
  2945. X_S_CLOSED , // Relationship is as strong as ordering
  2946. X_E_CLOSED , // Relationship is as strong as ordering
  2947. X_S ,
  2948. X_E ,
  2949. NULL ,
  2950. NULL
  2951. ) ;
  2952. t_Status = CheckValid(a_Overlap);
  2953. }
  2954. }
  2955. else if ( CompareSignedIntegerEqual ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S == X_E ), Start of Y and End Of X overlap
  2956. {
  2957. if ( CompareSignedIntegerLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  2958. {
  2959. // Order ( X_S < Y_S == X_E < Y_E )
  2960. if ( X_E_CLOSED || Y_S_CLOSED )
  2961. {
  2962. a_Overlap = new WmiSignedIntegerRangeNode (
  2963. m_PropertyName ,
  2964. m_Index ,
  2965. X_S_INFINITE,
  2966. Y_E_INFINITE ,
  2967. X_S_CLOSED ,
  2968. Y_E_CLOSED ,
  2969. X_S ,
  2970. Y_E ,
  2971. NULL ,
  2972. NULL
  2973. ) ;
  2974. t_Status = CheckValid(a_Overlap);
  2975. }
  2976. }
  2977. else if ( CompareSignedIntegerEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  2978. {
  2979. // Order ( X_S < Y_S == X_E == Y_E )
  2980. if ( X_E_CLOSED || Y_S_CLOSED )
  2981. {
  2982. a_Overlap = new WmiSignedIntegerRangeNode (
  2983. m_PropertyName ,
  2984. m_Index ,
  2985. X_S_INFINITE ,
  2986. Y_E_INFINITE,
  2987. X_S_CLOSED ,
  2988. X_E_CLOSED || Y_E_CLOSED || Y_S_CLOSED ,
  2989. X_S ,
  2990. Y_E ,
  2991. NULL ,
  2992. NULL
  2993. ) ;
  2994. t_Status = CheckValid(a_Overlap);
  2995. }
  2996. }
  2997. else if ( CompareSignedIntegerGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  2998. {
  2999. _DBG_ASSERT(FALSE);
  3000. }
  3001. }
  3002. else if ( CompareSignedIntegerGreater ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S > X_E )
  3003. {
  3004. // Order ( X_S < Y_S , X_E < Y_S ) Non overlapping
  3005. if ( X_E_CLOSED && Y_S_CLOSED )
  3006. {
  3007. if ( Y_S - X_E == 1 )
  3008. {
  3009. a_Overlap = new WmiSignedIntegerRangeNode (
  3010. m_PropertyName ,
  3011. m_Index ,
  3012. X_S_INFINITE,
  3013. Y_E_INFINITE ,
  3014. X_S_CLOSED ,
  3015. Y_E_CLOSED ,
  3016. X_S ,
  3017. Y_S ,
  3018. NULL ,
  3019. NULL
  3020. ) ;
  3021. t_Status = CheckValid(a_Overlap);
  3022. }
  3023. }
  3024. }
  3025. }
  3026. else if ( CompareSignedIntegerEqual ( X_S , X_S_INFINITE ? -1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S == Y_S )
  3027. {
  3028. if ( CompareSignedIntegerLess ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S < X_E )
  3029. {
  3030. if ( CompareSignedIntegerLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  3031. {
  3032. // Order ( X_S == Y_S < X_E < Y_E )
  3033. // Range ( X_S , Y_E )
  3034. a_Overlap = new WmiSignedIntegerRangeNode (
  3035. m_PropertyName ,
  3036. m_Index ,
  3037. X_S_INFINITE ,
  3038. Y_E_INFINITE ,
  3039. X_S_CLOSED || Y_S_CLOSED , // Check for weak relationship ( < , > )
  3040. Y_E_CLOSED , // Relationship is as strong as ordering
  3041. X_S ,
  3042. Y_E ,
  3043. NULL ,
  3044. NULL
  3045. ) ;
  3046. t_Status = CheckValid(a_Overlap);
  3047. }
  3048. else if ( CompareSignedIntegerEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  3049. {
  3050. // Order ( X_S == Y_S < X_E == Y_E )
  3051. // Range ( X_S , Y_E )
  3052. a_Overlap = new WmiSignedIntegerRangeNode (
  3053. m_PropertyName ,
  3054. m_Index ,
  3055. X_S_INFINITE ,
  3056. Y_E_INFINITE ,
  3057. X_S_CLOSED || Y_S_CLOSED , // Check for weak relationship ( < , > )
  3058. X_E_CLOSED || Y_E_CLOSED , // Check for weak relationship ( < , > )
  3059. X_S ,
  3060. Y_E ,
  3061. NULL ,
  3062. NULL
  3063. ) ;
  3064. t_Status = CheckValid(a_Overlap);
  3065. }
  3066. else if ( CompareSignedIntegerGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  3067. {
  3068. // Order ( X_S == Y_S < Y_E < X_E )
  3069. // Range ( X_S , X_E )
  3070. a_Overlap = new WmiSignedIntegerRangeNode (
  3071. m_PropertyName ,
  3072. m_Index ,
  3073. X_S_INFINITE ,
  3074. X_E_INFINITE ,
  3075. X_S_CLOSED || Y_S_CLOSED , // Check for weak relationship ( < , > )
  3076. X_E_CLOSED , // Relationship is as strong as ordering
  3077. X_S ,
  3078. X_E ,
  3079. NULL ,
  3080. NULL
  3081. ) ;
  3082. t_Status = CheckValid(a_Overlap);
  3083. }
  3084. }
  3085. else if ( CompareSignedIntegerEqual ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S == X_E ), Start of Y and End Of X overlap
  3086. {
  3087. if ( CompareSignedIntegerLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  3088. {
  3089. // Order ( X_S == Y_S == X_E < Y_E )
  3090. a_Overlap = new WmiSignedIntegerRangeNode (
  3091. m_PropertyName ,
  3092. m_Index ,
  3093. X_S_INFINITE ,
  3094. Y_E_INFINITE ,
  3095. X_S_CLOSED || Y_S_CLOSED || X_E_CLOSED ,
  3096. Y_E_CLOSED ,
  3097. Y_S ,
  3098. Y_E ,
  3099. NULL ,
  3100. NULL
  3101. ) ;
  3102. t_Status = CheckValid(a_Overlap);
  3103. }
  3104. else if ( CompareSignedIntegerEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  3105. {
  3106. // Order ( X_S == Y_S == X_E == Y_E )
  3107. a_Overlap = new WmiSignedIntegerRangeNode (
  3108. m_PropertyName ,
  3109. m_Index ,
  3110. X_S_INFINITE ,
  3111. X_S_INFINITE ,
  3112. TRUE ,
  3113. TRUE ,
  3114. X_S ,
  3115. X_S ,
  3116. NULL ,
  3117. NULL
  3118. ) ;
  3119. t_Status = CheckValid(a_Overlap);
  3120. }
  3121. else if ( CompareSignedIntegerGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  3122. {
  3123. _DBG_ASSERT(FALSE);
  3124. }
  3125. }
  3126. else if ( CompareSignedIntegerGreater ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S > X_E )
  3127. {
  3128. _DBG_ASSERT(FALSE);
  3129. }
  3130. }
  3131. else if ( CompareSignedIntegerGreater ( X_S , X_S_INFINITE ? -1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S > Y_S )
  3132. {
  3133. if ( CompareSignedIntegerLess ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S < Y_E )
  3134. {
  3135. if ( CompareSignedIntegerLess ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E < X_E )
  3136. {
  3137. // Order ( Y_S < X_S < Y_E < X_E )
  3138. // Range ( Y_S , X_E )
  3139. a_Overlap = new WmiSignedIntegerRangeNode (
  3140. m_PropertyName ,
  3141. m_Index ,
  3142. Y_S_INFINITE ,
  3143. X_E_INFINITE ,
  3144. Y_S_CLOSED , // Relationship is as strong as ordering
  3145. X_E_CLOSED , // Relationship is as strong as ordering
  3146. Y_S ,
  3147. X_E ,
  3148. NULL ,
  3149. NULL
  3150. ) ;
  3151. t_Status = CheckValid(a_Overlap);
  3152. }
  3153. else if ( CompareSignedIntegerEqual ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E == X_E )
  3154. {
  3155. // Order ( Y_S < X_S < Y_E == X_E )
  3156. // Range ( Y_S , X_E )
  3157. a_Overlap = new WmiSignedIntegerRangeNode (
  3158. m_PropertyName ,
  3159. m_Index ,
  3160. Y_S_INFINITE ,
  3161. Y_E_INFINITE ,
  3162. Y_S_CLOSED , // Relationship is as strong as ordering
  3163. Y_E_CLOSED || X_E_CLOSED , // Check for weak relationship ( < , > )
  3164. Y_S ,
  3165. Y_E ,
  3166. NULL ,
  3167. NULL
  3168. ) ;
  3169. t_Status = CheckValid(a_Overlap);
  3170. }
  3171. else if ( CompareSignedIntegerGreater ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E > X_E )
  3172. {
  3173. // Order ( Y_S < X_S < X_E < Y_E )
  3174. // Range ( Y_S , Y_E )
  3175. a_Overlap = new WmiSignedIntegerRangeNode (
  3176. m_PropertyName ,
  3177. m_Index ,
  3178. Y_S_INFINITE ,
  3179. Y_E_INFINITE ,
  3180. Y_S_CLOSED , // Relationship is as strong as ordering
  3181. Y_E_CLOSED , // Relationship is as strong as ordering
  3182. Y_S ,
  3183. Y_E ,
  3184. NULL ,
  3185. NULL
  3186. ) ;
  3187. t_Status = CheckValid(a_Overlap);
  3188. }
  3189. }
  3190. else if ( CompareSignedIntegerEqual ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S == Y_E ), Start of X and End Of Y overlap
  3191. {
  3192. if ( CompareSignedIntegerLess ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E < X_E )
  3193. {
  3194. if ( X_S_CLOSED || Y_E_CLOSED )
  3195. {
  3196. a_Overlap = new WmiSignedIntegerRangeNode (
  3197. m_PropertyName ,
  3198. m_Index ,
  3199. Y_S_INFINITE ,
  3200. X_E_INFINITE,
  3201. Y_S_CLOSED ,
  3202. X_E_CLOSED ,
  3203. Y_S ,
  3204. X_E ,
  3205. NULL ,
  3206. NULL
  3207. ) ;
  3208. t_Status = CheckValid(a_Overlap);
  3209. }
  3210. }
  3211. else if ( CompareSignedIntegerEqual ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E == X_E )
  3212. {
  3213. // Order ( Y_S < X_S == Y_E == X_E )
  3214. a_Overlap = new WmiSignedIntegerRangeNode (
  3215. m_PropertyName ,
  3216. m_Index ,
  3217. Y_S_INFINITE ,
  3218. X_E_INFINITE ,
  3219. Y_S_CLOSED ,
  3220. TRUE ,
  3221. Y_S ,
  3222. X_E ,
  3223. NULL ,
  3224. NULL
  3225. ) ;
  3226. t_Status = CheckValid(a_Overlap);
  3227. }
  3228. else if ( CompareSignedIntegerGreater ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E > X_E )
  3229. {
  3230. // Order ( Y_S < X_S == X_E < Y_E )
  3231. a_Overlap = new WmiSignedIntegerRangeNode (
  3232. m_PropertyName ,
  3233. m_Index ,
  3234. Y_S_INFINITE ,
  3235. Y_E_INFINITE ,
  3236. Y_S_CLOSED ,
  3237. Y_E_CLOSED ,
  3238. Y_S ,
  3239. Y_E ,
  3240. NULL ,
  3241. NULL
  3242. ) ;
  3243. t_Status = CheckValid(a_Overlap);
  3244. }
  3245. }
  3246. else if ( CompareSignedIntegerGreater ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S > Y_E )
  3247. {
  3248. // Order ( Y_S < Y_E < X_S ) Non Overlapping
  3249. if ( Y_E_CLOSED && X_S_CLOSED )
  3250. {
  3251. if ( X_S - Y_E == - 1 )
  3252. {
  3253. a_Overlap = new WmiSignedIntegerRangeNode (
  3254. m_PropertyName ,
  3255. m_Index ,
  3256. Y_S_INFINITE,
  3257. X_E_INFINITE ,
  3258. Y_S_CLOSED ,
  3259. X_E_CLOSED ,
  3260. Y_S ,
  3261. X_S ,
  3262. NULL ,
  3263. NULL
  3264. ) ;
  3265. t_Status = CheckValid(a_Overlap);
  3266. }
  3267. }
  3268. }
  3269. }
  3270. return t_Status ;
  3271. }
  3272. /******************************************************************************
  3273. *
  3274. * Name:
  3275. *
  3276. *
  3277. * Description:
  3278. *
  3279. *
  3280. *****************************************************************************/
  3281. WmiTriState WmiUnsignedIntegerRangeNode :: GetOverlappingRange (
  3282. WmiUnsignedIntegerRangeNode &a_UnsignedInteger ,
  3283. WmiUnsignedIntegerRangeNode *&a_Overlap
  3284. )
  3285. {
  3286. WmiTriState t_Status = :: State_False ;
  3287. // A weak ( open ) relationship is ( < , > )
  3288. // A strong ( closed ) relationship is ( == , <= , >= )
  3289. a_Overlap = NULL ;
  3290. ULONG X_S = m_LowerBound ;
  3291. ULONG X_E = m_UpperBound ;
  3292. ULONG Y_S = a_UnsignedInteger.m_LowerBound ;
  3293. ULONG Y_E = a_UnsignedInteger.m_UpperBound ;
  3294. BOOL X_S_CLOSED = m_LowerBoundClosed ;
  3295. BOOL X_E_CLOSED = m_UpperBoundClosed ;
  3296. BOOL Y_S_CLOSED = a_UnsignedInteger.m_LowerBoundClosed ;
  3297. BOOL Y_E_CLOSED = a_UnsignedInteger.m_UpperBoundClosed ;
  3298. BOOL X_S_INFINITE = m_InfiniteLowerBound ;
  3299. BOOL X_E_INFINITE = m_InfiniteUpperBound ;
  3300. BOOL Y_S_INFINITE = a_UnsignedInteger.m_InfiniteLowerBound ;
  3301. BOOL Y_E_INFINITE = a_UnsignedInteger.m_InfiniteUpperBound ;
  3302. if ( CompareUnsignedIntegerLess ( X_S , X_S_INFINITE ? - 1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S < Y_S )
  3303. {
  3304. if ( CompareUnsignedIntegerLess ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S < X_E )
  3305. {
  3306. if ( CompareUnsignedIntegerLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  3307. {
  3308. // Order ( X_S < Y_S < X_E < Y_E )
  3309. // Range ( X_S , Y_E )
  3310. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3311. m_PropertyName ,
  3312. m_Index ,
  3313. X_S_INFINITE ,
  3314. Y_E_INFINITE ,
  3315. X_S_CLOSED , // Relationship is as strong as ordering
  3316. Y_E_CLOSED , // Relationship is as strong as ordering
  3317. X_S ,
  3318. Y_E ,
  3319. NULL ,
  3320. NULL
  3321. ) ;
  3322. t_Status = CheckValid(a_Overlap);
  3323. }
  3324. else if ( CompareUnsignedIntegerEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  3325. {
  3326. // Order ( X_S < Y_S < X_E == Y_E )
  3327. // Range ( X_S , X_E )
  3328. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3329. m_PropertyName ,
  3330. m_Index ,
  3331. X_S_INFINITE ,
  3332. X_E_INFINITE ,
  3333. X_S_CLOSED , // Relationship is as strong as ordering
  3334. X_E_CLOSED || Y_E_CLOSED , // Check for weak relationship ( < , > )
  3335. X_S ,
  3336. X_E ,
  3337. NULL ,
  3338. NULL
  3339. ) ;
  3340. t_Status = CheckValid(a_Overlap);
  3341. }
  3342. else if ( CompareUnsignedIntegerGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  3343. {
  3344. // Order ( X_S < Y_S < Y_E < X_E )
  3345. // Range ( X_S , X_E )
  3346. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3347. m_PropertyName ,
  3348. m_Index ,
  3349. X_S_INFINITE ,
  3350. X_E_INFINITE ,
  3351. X_S_CLOSED , // Relationship is as strong as ordering
  3352. X_E_CLOSED , // Relationship is as strong as ordering
  3353. X_S ,
  3354. X_E ,
  3355. NULL ,
  3356. NULL
  3357. ) ;
  3358. t_Status = CheckValid(a_Overlap);
  3359. }
  3360. }
  3361. else if ( CompareUnsignedIntegerEqual ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S == X_E ), Start of Y and End Of X overlap
  3362. {
  3363. if ( CompareUnsignedIntegerLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  3364. {
  3365. // Order ( X_S < Y_S == X_E < Y_E )
  3366. if ( X_E_CLOSED || Y_S_CLOSED )
  3367. {
  3368. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3369. m_PropertyName ,
  3370. m_Index ,
  3371. X_S_INFINITE,
  3372. Y_E_INFINITE ,
  3373. X_S_CLOSED ,
  3374. Y_E_CLOSED ,
  3375. X_S ,
  3376. Y_E ,
  3377. NULL ,
  3378. NULL
  3379. ) ;
  3380. t_Status = CheckValid(a_Overlap);
  3381. }
  3382. }
  3383. else if ( CompareUnsignedIntegerEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  3384. {
  3385. // Order ( X_S < Y_S == X_E == Y_E )
  3386. if ( X_E_CLOSED || Y_S_CLOSED )
  3387. {
  3388. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3389. m_PropertyName ,
  3390. m_Index ,
  3391. X_S_INFINITE ,
  3392. Y_E_INFINITE,
  3393. X_S_CLOSED ,
  3394. X_E_CLOSED || Y_E_CLOSED || Y_S_CLOSED ,
  3395. X_S ,
  3396. Y_E ,
  3397. NULL ,
  3398. NULL
  3399. ) ;
  3400. t_Status = CheckValid(a_Overlap);
  3401. }
  3402. }
  3403. else if ( CompareUnsignedIntegerGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  3404. {
  3405. // Order ( X_S < Y_E < Y_S == X_E ) Can never happen
  3406. _DBG_ASSERT(FALSE);
  3407. }
  3408. }
  3409. else if ( CompareUnsignedIntegerGreater ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S > X_E )
  3410. {
  3411. // Order ( X_S < Y_S , X_E < Y_S ) Non overlapping
  3412. if ( X_E_CLOSED && Y_S_CLOSED )
  3413. {
  3414. if ( Y_S - X_E == 1 )
  3415. {
  3416. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3417. m_PropertyName ,
  3418. m_Index ,
  3419. X_S_INFINITE,
  3420. Y_E_INFINITE ,
  3421. X_S_CLOSED ,
  3422. Y_E_CLOSED ,
  3423. X_S ,
  3424. Y_S ,
  3425. NULL ,
  3426. NULL
  3427. ) ;
  3428. t_Status = CheckValid(a_Overlap);
  3429. }
  3430. }
  3431. }
  3432. }
  3433. else if ( CompareUnsignedIntegerEqual ( X_S , X_S_INFINITE ? -1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S == Y_S )
  3434. {
  3435. if ( CompareUnsignedIntegerLess ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S < X_E )
  3436. {
  3437. if ( CompareUnsignedIntegerLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  3438. {
  3439. // Order ( X_S == Y_S < X_E < Y_E )
  3440. // Range ( X_S , Y_E )
  3441. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3442. m_PropertyName ,
  3443. m_Index ,
  3444. X_S_INFINITE ,
  3445. Y_E_INFINITE ,
  3446. X_S_CLOSED || Y_S_CLOSED , // Check for weak relationship ( < , > )
  3447. Y_E_CLOSED , // Relationship is as strong as ordering
  3448. X_S ,
  3449. Y_E ,
  3450. NULL ,
  3451. NULL
  3452. ) ;
  3453. t_Status = CheckValid(a_Overlap);
  3454. }
  3455. else if ( CompareUnsignedIntegerEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  3456. {
  3457. // Order ( X_S == Y_S < X_E == Y_E )
  3458. // Range ( X_S , Y_E )
  3459. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3460. m_PropertyName ,
  3461. m_Index ,
  3462. X_S_INFINITE ,
  3463. Y_E_INFINITE ,
  3464. X_S_CLOSED || Y_S_CLOSED , // Check for weak relationship ( < , > )
  3465. X_E_CLOSED || Y_E_CLOSED , // Check for weak relationship ( < , > )
  3466. X_S ,
  3467. Y_E ,
  3468. NULL ,
  3469. NULL
  3470. ) ;
  3471. t_Status = CheckValid(a_Overlap);
  3472. }
  3473. else if ( CompareUnsignedIntegerGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  3474. {
  3475. // Order ( X_S == Y_S < Y_E < X_E )
  3476. // Range ( X_S , X_E )
  3477. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3478. m_PropertyName ,
  3479. m_Index ,
  3480. X_S_INFINITE ,
  3481. X_E_INFINITE ,
  3482. X_S_CLOSED || Y_S_CLOSED , // Check for weak relationship ( < , > )
  3483. X_E_CLOSED , // Relationship is as strong as ordering
  3484. X_S ,
  3485. X_E ,
  3486. NULL ,
  3487. NULL
  3488. ) ;
  3489. t_Status = CheckValid(a_Overlap);
  3490. }
  3491. }
  3492. else if ( CompareUnsignedIntegerEqual ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S == X_E ), Start of Y and End Of X overlap
  3493. {
  3494. if ( CompareUnsignedIntegerLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  3495. {
  3496. // Order ( X_S == Y_S == X_E < Y_E )
  3497. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3498. m_PropertyName ,
  3499. m_Index ,
  3500. X_S_INFINITE ,
  3501. Y_E_INFINITE ,
  3502. X_S_CLOSED || Y_S_CLOSED || X_E_CLOSED ,
  3503. Y_E_CLOSED ,
  3504. Y_S ,
  3505. Y_E ,
  3506. NULL ,
  3507. NULL
  3508. ) ;
  3509. t_Status = CheckValid(a_Overlap);
  3510. }
  3511. else if ( CompareUnsignedIntegerEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  3512. {
  3513. // Order ( X_S == Y_S == X_E == Y_E )
  3514. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3515. m_PropertyName ,
  3516. m_Index ,
  3517. X_S_INFINITE ,
  3518. X_S_INFINITE ,
  3519. TRUE ,
  3520. TRUE ,
  3521. X_S ,
  3522. X_S ,
  3523. NULL ,
  3524. NULL
  3525. ) ;
  3526. t_Status = CheckValid(a_Overlap);
  3527. }
  3528. else if ( CompareUnsignedIntegerGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  3529. {
  3530. _DBG_ASSERT(FALSE);
  3531. }
  3532. }
  3533. else if ( CompareUnsignedIntegerGreater ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S > X_E )
  3534. {
  3535. _DBG_ASSERT(FALSE);
  3536. }
  3537. }
  3538. else if ( CompareUnsignedIntegerGreater ( X_S , X_S_INFINITE ? -1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S > Y_S )
  3539. {
  3540. if ( CompareUnsignedIntegerLess ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S < Y_E )
  3541. {
  3542. if ( CompareUnsignedIntegerLess ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E < X_E )
  3543. {
  3544. // Order ( Y_S < X_S < Y_E < X_E )
  3545. // Range ( Y_S , X_E )
  3546. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3547. m_PropertyName ,
  3548. m_Index ,
  3549. Y_S_INFINITE ,
  3550. X_E_INFINITE ,
  3551. Y_S_CLOSED , // Relationship is as strong as ordering
  3552. X_E_CLOSED , // Relationship is as strong as ordering
  3553. Y_S ,
  3554. X_E ,
  3555. NULL ,
  3556. NULL
  3557. ) ;
  3558. t_Status = ( a_Overlap ) ? ( :: State_True ) : ( :: State_Error ) ;
  3559. }
  3560. else if ( CompareUnsignedIntegerEqual ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E == X_E )
  3561. {
  3562. // Order ( Y_S < X_S < Y_E == X_E )
  3563. // Range ( Y_S , X_E )
  3564. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3565. m_PropertyName ,
  3566. m_Index ,
  3567. Y_S_INFINITE ,
  3568. Y_E_INFINITE ,
  3569. Y_S_CLOSED , // Relationship is as strong as ordering
  3570. Y_E_CLOSED || X_E_CLOSED , // Check for weak relationship ( < , > )
  3571. Y_S ,
  3572. Y_E ,
  3573. NULL ,
  3574. NULL
  3575. ) ;
  3576. t_Status = CheckValid(a_Overlap);
  3577. }
  3578. else if ( CompareUnsignedIntegerGreater ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E > X_E )
  3579. {
  3580. // Order ( Y_S < X_S < X_E < Y_E )
  3581. // Range ( Y_S , Y_E )
  3582. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3583. m_PropertyName ,
  3584. m_Index ,
  3585. Y_S_INFINITE ,
  3586. Y_E_INFINITE ,
  3587. Y_S_CLOSED , // Relationship is as strong as ordering
  3588. Y_E_CLOSED , // Relationship is as strong as ordering
  3589. Y_S ,
  3590. Y_E ,
  3591. NULL ,
  3592. NULL
  3593. ) ;
  3594. t_Status = CheckValid(a_Overlap);
  3595. }
  3596. }
  3597. else if ( CompareUnsignedIntegerEqual ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S == Y_E ), Start of X and End Of Y overlap
  3598. {
  3599. if ( CompareUnsignedIntegerLess ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E < X_E )
  3600. {
  3601. if ( X_S_CLOSED || Y_E_CLOSED )
  3602. {
  3603. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3604. m_PropertyName ,
  3605. m_Index ,
  3606. Y_S_INFINITE ,
  3607. X_E_INFINITE,
  3608. Y_S_CLOSED ,
  3609. X_E_CLOSED ,
  3610. Y_S ,
  3611. X_E ,
  3612. NULL ,
  3613. NULL
  3614. ) ;
  3615. t_Status = CheckValid(a_Overlap);
  3616. }
  3617. }
  3618. else if ( CompareUnsignedIntegerEqual ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E == X_E )
  3619. {
  3620. // Order ( Y_S < X_S == Y_E == X_E )
  3621. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3622. m_PropertyName ,
  3623. m_Index ,
  3624. Y_S_INFINITE ,
  3625. X_E_INFINITE ,
  3626. Y_S_CLOSED ,
  3627. TRUE ,
  3628. Y_S ,
  3629. X_E ,
  3630. NULL ,
  3631. NULL
  3632. ) ;
  3633. t_Status = CheckValid(a_Overlap);
  3634. }
  3635. else if ( CompareUnsignedIntegerGreater ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E > X_E )
  3636. {
  3637. // Order ( Y_S < X_S == X_E < Y_E )
  3638. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3639. m_PropertyName ,
  3640. m_Index ,
  3641. Y_S_INFINITE ,
  3642. Y_E_INFINITE ,
  3643. Y_S_CLOSED ,
  3644. Y_E_CLOSED ,
  3645. Y_S ,
  3646. Y_E ,
  3647. NULL ,
  3648. NULL
  3649. ) ;
  3650. t_Status = CheckValid(a_Overlap);
  3651. }
  3652. }
  3653. else if ( CompareUnsignedIntegerGreater ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S > Y_E )
  3654. {
  3655. // Order ( Y_S < Y_E < X_S ) Non Overlapping
  3656. if ( Y_E_CLOSED && X_S_CLOSED )
  3657. {
  3658. if ( X_S - Y_E == -1 )
  3659. {
  3660. a_Overlap = new WmiUnsignedIntegerRangeNode (
  3661. m_PropertyName ,
  3662. m_Index ,
  3663. Y_S_INFINITE,
  3664. X_E_INFINITE ,
  3665. Y_S_CLOSED ,
  3666. X_E_CLOSED ,
  3667. Y_S ,
  3668. X_S ,
  3669. NULL ,
  3670. NULL
  3671. ) ;
  3672. t_Status = CheckValid(a_Overlap);
  3673. }
  3674. }
  3675. }
  3676. }
  3677. return t_Status ;
  3678. }
  3679. /******************************************************************************
  3680. *
  3681. * Name:
  3682. *
  3683. *
  3684. * Description:
  3685. *
  3686. *
  3687. *****************************************************************************/
  3688. WmiTriState WmiStringRangeNode :: GetOverlappingRange (
  3689. WmiStringRangeNode &a_String ,
  3690. WmiStringRangeNode *&a_Overlap
  3691. )
  3692. {
  3693. WmiTriState t_Status = :: State_False ;
  3694. // A weak ( open ) relationship is ( < , > )
  3695. // A strong ( closed ) relationship is ( == , <= , >= )
  3696. a_Overlap = NULL ;
  3697. BSTR X_S = m_LowerBound ;
  3698. BSTR X_E = m_UpperBound ;
  3699. BSTR Y_S = a_String.m_LowerBound ;
  3700. BSTR Y_E = a_String.m_UpperBound ;
  3701. BOOL X_S_CLOSED = m_LowerBoundClosed ;
  3702. BOOL X_E_CLOSED = m_UpperBoundClosed ;
  3703. BOOL Y_S_CLOSED = a_String.m_LowerBoundClosed ;
  3704. BOOL Y_E_CLOSED = a_String.m_UpperBoundClosed ;
  3705. BOOL X_S_INFINITE = m_InfiniteLowerBound ;
  3706. BOOL X_E_INFINITE = m_InfiniteUpperBound ;
  3707. BOOL Y_S_INFINITE = a_String.m_InfiniteLowerBound ;
  3708. BOOL Y_E_INFINITE = a_String.m_InfiniteUpperBound ;
  3709. if ( CompareStringLess ( X_S , X_S_INFINITE ? - 1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S < Y_S )
  3710. {
  3711. if ( CompareStringLess ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S < X_E )
  3712. {
  3713. if ( CompareStringLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  3714. {
  3715. // Order ( X_S < Y_S < X_E < Y_E )
  3716. // Range ( X_S , Y_E )
  3717. a_Overlap = new WmiStringRangeNode (
  3718. m_PropertyName ,
  3719. m_Index ,
  3720. X_S_INFINITE ,
  3721. Y_E_INFINITE ,
  3722. X_S_CLOSED , // Relationship is as strong as ordering
  3723. Y_E_CLOSED , // Relationship is as strong as ordering
  3724. X_S ,
  3725. Y_E ,
  3726. NULL ,
  3727. NULL
  3728. ) ;
  3729. t_Status = CheckValid(a_Overlap);
  3730. }
  3731. else if ( CompareStringEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  3732. {
  3733. // Order ( X_S < Y_S < X_E == Y_E )
  3734. // Range ( X_S , X_E )
  3735. a_Overlap = new WmiStringRangeNode (
  3736. m_PropertyName ,
  3737. m_Index ,
  3738. X_S_INFINITE ,
  3739. X_E_INFINITE ,
  3740. X_S_CLOSED , // Relationship is as strong as ordering
  3741. X_E_CLOSED || Y_E_CLOSED , // Check for weak relationship ( < , > )
  3742. X_S ,
  3743. X_E ,
  3744. NULL ,
  3745. NULL
  3746. ) ;
  3747. t_Status = CheckValid(a_Overlap);
  3748. }
  3749. else if ( CompareStringGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  3750. {
  3751. // Order ( X_S < Y_S < Y_E < X_E )
  3752. // Range ( X_S , X_E )
  3753. a_Overlap = new WmiStringRangeNode (
  3754. m_PropertyName ,
  3755. m_Index ,
  3756. X_S_INFINITE ,
  3757. X_E_INFINITE ,
  3758. X_S_CLOSED , // Relationship is as strong as ordering
  3759. X_E_CLOSED , // Relationship is as strong as ordering
  3760. X_S ,
  3761. X_E ,
  3762. NULL ,
  3763. NULL
  3764. ) ;
  3765. t_Status = CheckValid(a_Overlap);
  3766. }
  3767. }
  3768. else if ( CompareStringEqual ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S == X_E ), Start of Y and End Of X overlap
  3769. {
  3770. if ( CompareStringLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  3771. {
  3772. // Order ( X_S < Y_S == X_E < Y_E )
  3773. if ( X_E_CLOSED || Y_S_CLOSED )
  3774. {
  3775. a_Overlap = new WmiStringRangeNode (
  3776. m_PropertyName ,
  3777. m_Index ,
  3778. X_S_INFINITE,
  3779. Y_E_INFINITE ,
  3780. X_S_CLOSED ,
  3781. Y_E_CLOSED ,
  3782. X_S ,
  3783. Y_E ,
  3784. NULL ,
  3785. NULL
  3786. ) ;
  3787. t_Status = CheckValid(a_Overlap);
  3788. }
  3789. }
  3790. else if ( CompareStringEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  3791. {
  3792. // Order ( X_S < Y_S == X_E == Y_E )
  3793. if ( X_E_CLOSED || Y_S_CLOSED )
  3794. {
  3795. a_Overlap = new WmiStringRangeNode (
  3796. m_PropertyName ,
  3797. m_Index ,
  3798. X_S_INFINITE ,
  3799. Y_E_INFINITE,
  3800. X_S_CLOSED ,
  3801. X_E_CLOSED || Y_E_CLOSED || Y_S_CLOSED ,
  3802. X_S ,
  3803. Y_E ,
  3804. NULL ,
  3805. NULL
  3806. ) ;
  3807. t_Status = CheckValid(a_Overlap);
  3808. }
  3809. }
  3810. else if ( CompareStringGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  3811. {
  3812. // Order ( X_S < Y_E < Y_S == X_E ) Can never happen
  3813. _DBG_ASSERT(FALSE);
  3814. }
  3815. }
  3816. else if ( CompareStringGreater ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S > X_E )
  3817. {
  3818. // Order ( X_S < Y_S , X_E < Y_S ) Non overlapping
  3819. }
  3820. }
  3821. else if ( CompareStringEqual ( X_S , X_S_INFINITE ? -1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S == Y_S )
  3822. {
  3823. if ( CompareStringLess ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S < X_E )
  3824. {
  3825. if ( CompareStringLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  3826. {
  3827. // Order ( X_S == Y_S < X_E < Y_E )
  3828. // Range ( X_S , Y_E )
  3829. a_Overlap = new WmiStringRangeNode (
  3830. m_PropertyName ,
  3831. m_Index ,
  3832. X_S_INFINITE ,
  3833. Y_E_INFINITE ,
  3834. X_S_CLOSED || Y_S_CLOSED , // Check for weak relationship ( < , > )
  3835. Y_E_CLOSED , // Relationship is as strong as ordering
  3836. X_S ,
  3837. Y_E ,
  3838. NULL ,
  3839. NULL
  3840. ) ;
  3841. t_Status = CheckValid(a_Overlap);
  3842. }
  3843. else if ( CompareStringEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  3844. {
  3845. // Order ( X_S == Y_S < X_E == Y_E )
  3846. // Range ( X_S , Y_E )
  3847. a_Overlap = new WmiStringRangeNode (
  3848. m_PropertyName ,
  3849. m_Index ,
  3850. X_S_INFINITE ,
  3851. Y_E_INFINITE ,
  3852. X_S_CLOSED || Y_S_CLOSED , // Check for weak relationship ( < , > )
  3853. X_E_CLOSED || Y_E_CLOSED , // Check for weak relationship ( < , > )
  3854. X_S ,
  3855. Y_E ,
  3856. NULL ,
  3857. NULL
  3858. ) ;
  3859. t_Status = CheckValid(a_Overlap);
  3860. }
  3861. else if ( CompareStringGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  3862. {
  3863. // Order ( X_S == Y_S < Y_E < X_E )
  3864. // Range ( X_S , X_E )
  3865. a_Overlap = new WmiStringRangeNode (
  3866. m_PropertyName ,
  3867. m_Index ,
  3868. X_S_INFINITE ,
  3869. X_E_INFINITE ,
  3870. X_S_CLOSED || Y_S_CLOSED , // Check for weak relationship ( < , > )
  3871. X_E_CLOSED , // Relationship is as strong as ordering
  3872. X_S ,
  3873. X_E ,
  3874. NULL ,
  3875. NULL
  3876. ) ;
  3877. t_Status = CheckValid(a_Overlap);
  3878. }
  3879. }
  3880. else if ( CompareStringEqual ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S == X_E ), Start of Y and End Of X overlap
  3881. {
  3882. if ( CompareStringLess ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E < Y_E )
  3883. {
  3884. // Order ( X_S == Y_S == X_E < Y_E )
  3885. if ( X_E_CLOSED || Y_S_CLOSED )
  3886. {
  3887. a_Overlap = new WmiStringRangeNode (
  3888. m_PropertyName ,
  3889. m_Index ,
  3890. X_S_INFINITE ,
  3891. Y_E_INFINITE ,
  3892. X_S_CLOSED || Y_S_CLOSED || X_E_CLOSED ,
  3893. Y_E_CLOSED ,
  3894. Y_S ,
  3895. Y_E ,
  3896. NULL ,
  3897. NULL
  3898. ) ;
  3899. t_Status = CheckValid(a_Overlap);
  3900. }
  3901. }
  3902. else if ( CompareStringEqual ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E == Y_E )
  3903. {
  3904. // Order ( X_S == Y_S == X_E == Y_E )
  3905. a_Overlap = new WmiStringRangeNode (
  3906. m_PropertyName ,
  3907. m_Index ,
  3908. X_S_INFINITE ,
  3909. X_S_INFINITE ,
  3910. TRUE ,
  3911. TRUE ,
  3912. X_S ,
  3913. X_S ,
  3914. NULL ,
  3915. NULL
  3916. ) ;
  3917. t_Status = CheckValid(a_Overlap);
  3918. }
  3919. else if ( CompareStringGreater ( X_E , X_E_INFINITE ? 1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_E > Y_E )
  3920. {
  3921. _DBG_ASSERT(FALSE);
  3922. }
  3923. }
  3924. else if ( CompareStringGreater ( Y_S , Y_S_INFINITE ? -1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_S > X_E )
  3925. {
  3926. _DBG_ASSERT(FALSE);
  3927. }
  3928. }
  3929. else if ( CompareStringGreater ( X_S , X_S_INFINITE ? -1 : 0 , Y_S , Y_S_INFINITE ? -1 : 0 ) ) // ( X_S > Y_S )
  3930. {
  3931. if ( CompareStringLess ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S < Y_E )
  3932. {
  3933. if ( CompareStringLess ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E < X_E )
  3934. {
  3935. // Order ( Y_S < X_S < Y_E < X_E )
  3936. // Range ( Y_S , X_E )
  3937. a_Overlap = new WmiStringRangeNode (
  3938. m_PropertyName ,
  3939. m_Index ,
  3940. Y_S_INFINITE ,
  3941. X_E_INFINITE ,
  3942. Y_S_CLOSED , // Relationship is as strong as ordering
  3943. X_E_CLOSED , // Relationship is as strong as ordering
  3944. Y_S ,
  3945. X_E ,
  3946. NULL ,
  3947. NULL
  3948. ) ;
  3949. t_Status = CheckValid(a_Overlap);
  3950. }
  3951. else if ( CompareStringEqual ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E == X_E )
  3952. {
  3953. // Order ( Y_S < X_S < Y_E == X_E )
  3954. // Range ( Y_S , X_E )
  3955. a_Overlap = new WmiStringRangeNode (
  3956. m_PropertyName ,
  3957. m_Index ,
  3958. Y_S_INFINITE ,
  3959. Y_E_INFINITE ,
  3960. Y_S_CLOSED , // Relationship is as strong as ordering
  3961. Y_E_CLOSED || X_E_CLOSED , // Check for weak relationship ( < , > )
  3962. Y_S ,
  3963. Y_E ,
  3964. NULL ,
  3965. NULL
  3966. ) ;
  3967. t_Status = CheckValid(a_Overlap);
  3968. }
  3969. else if ( CompareStringGreater ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E > X_E )
  3970. {
  3971. // Order ( Y_S < X_S < X_E < Y_E )
  3972. // Range ( Y_S , Y_E )
  3973. a_Overlap = new WmiStringRangeNode (
  3974. m_PropertyName ,
  3975. m_Index ,
  3976. Y_S_INFINITE ,
  3977. Y_E_INFINITE ,
  3978. Y_S_CLOSED , // Relationship is as strong as ordering
  3979. Y_E_CLOSED , // Relationship is as strong as ordering
  3980. Y_S ,
  3981. Y_E ,
  3982. NULL ,
  3983. NULL
  3984. ) ;
  3985. t_Status = CheckValid(a_Overlap);
  3986. }
  3987. }
  3988. else if ( CompareStringEqual ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S == Y_E ), Start of X and End Of Y overlap
  3989. {
  3990. if ( CompareStringLess ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E < X_E )
  3991. {
  3992. if ( X_S_CLOSED || Y_E_CLOSED )
  3993. {
  3994. a_Overlap = new WmiStringRangeNode (
  3995. m_PropertyName ,
  3996. m_Index ,
  3997. Y_S_INFINITE ,
  3998. X_E_INFINITE,
  3999. Y_S_CLOSED ,
  4000. X_E_CLOSED ,
  4001. Y_S ,
  4002. X_E ,
  4003. NULL ,
  4004. NULL
  4005. ) ;
  4006. t_Status = CheckValid(a_Overlap);
  4007. }
  4008. }
  4009. else if ( CompareStringEqual ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E == X_E )
  4010. {
  4011. // Order ( Y_S < X_S == Y_E == X_E )
  4012. a_Overlap = new WmiStringRangeNode (
  4013. m_PropertyName ,
  4014. m_Index ,
  4015. Y_S_INFINITE ,
  4016. X_E_INFINITE ,
  4017. Y_S_CLOSED ,
  4018. TRUE ,
  4019. Y_S ,
  4020. X_E ,
  4021. NULL ,
  4022. NULL
  4023. ) ;
  4024. t_Status = CheckValid(a_Overlap);
  4025. }
  4026. else if ( CompareStringGreater ( Y_E , Y_E_INFINITE ? 1 : 0 , X_E , X_E_INFINITE ? 1 : 0 ) ) // ( Y_E > X_E )
  4027. {
  4028. // Order ( Y_S < X_S == X_E < Y_E )
  4029. a_Overlap = new WmiStringRangeNode (
  4030. m_PropertyName ,
  4031. m_Index ,
  4032. Y_S_INFINITE ,
  4033. Y_E_INFINITE ,
  4034. Y_S_CLOSED ,
  4035. Y_E_CLOSED ,
  4036. Y_S ,
  4037. Y_E ,
  4038. NULL ,
  4039. NULL
  4040. ) ;
  4041. t_Status = CheckValid(a_Overlap);
  4042. }
  4043. }
  4044. else if ( CompareStringGreater ( X_S , X_S_INFINITE ? -1 : 0 , Y_E , Y_E_INFINITE ? 1 : 0 ) ) // ( X_S > Y_E )
  4045. {
  4046. // Order ( Y_S < Y_E < X_S ) Non Overlapping
  4047. }
  4048. }
  4049. return t_Status ;
  4050. }
  4051. /******************************************************************************
  4052. *
  4053. * Name:
  4054. *
  4055. *
  4056. * Description:
  4057. *
  4058. *
  4059. *****************************************************************************/
  4060. WmiTriState WmiOperatorEqualNode :: GetRange (WmiRangeNode *& a_Range)
  4061. {
  4062. a_Range = NULL ;
  4063. WmiTriState t_Status = :: State_False ;
  4064. WmiTreeNode *t_Value = GetLeft () ;
  4065. if ( t_Value )
  4066. {
  4067. if ( t_Value->GetType () == TypeId_WmiUnsignedIntegerNode )
  4068. {
  4069. WmiUnsignedIntegerNode *t_Integer = ( WmiUnsignedIntegerNode * ) t_Value ;
  4070. a_Range = new WmiUnsignedIntegerRangeNode (
  4071. t_Integer->GetPropertyName () ,
  4072. t_Integer->GetIndex () ,
  4073. FALSE ,
  4074. FALSE ,
  4075. TRUE ,
  4076. TRUE ,
  4077. t_Integer->GetValue () ,
  4078. t_Integer->GetValue () ,
  4079. NULL ,
  4080. NULL
  4081. ) ;
  4082. t_Status = CheckValid(a_Range);
  4083. }
  4084. else if ( t_Value->GetType () == TypeId_WmiSignedIntegerNode )
  4085. {
  4086. WmiSignedIntegerNode *t_Integer = ( WmiSignedIntegerNode * ) t_Value ;
  4087. a_Range = new WmiSignedIntegerRangeNode (
  4088. t_Integer->GetPropertyName () ,
  4089. t_Integer->GetIndex () ,
  4090. FALSE ,
  4091. FALSE ,
  4092. TRUE ,
  4093. TRUE ,
  4094. t_Integer->GetValue () ,
  4095. t_Integer->GetValue () ,
  4096. NULL ,
  4097. NULL
  4098. ) ;
  4099. t_Status = CheckValid(a_Range);
  4100. }
  4101. else if ( t_Value->GetType () == TypeId_WmiStringNode )
  4102. {
  4103. WmiStringNode *t_String = ( WmiStringNode * ) t_Value ;
  4104. if ( t_String->GetPropertyFunction () == WmiValueNode :: WmiValueFunction :: Function_None )
  4105. {
  4106. a_Range = new WmiStringRangeNode (
  4107. t_String->GetPropertyName () ,
  4108. t_String->GetIndex () ,
  4109. FALSE ,
  4110. FALSE ,
  4111. TRUE ,
  4112. TRUE ,
  4113. t_String->GetValue () ,
  4114. t_String->GetValue () ,
  4115. NULL ,
  4116. NULL
  4117. ) ;
  4118. t_Status = CheckValid(a_Range);
  4119. }
  4120. else
  4121. {
  4122. a_Range = new WmiStringRangeNode (
  4123. t_String->GetPropertyName () ,
  4124. t_String->GetIndex () ,
  4125. TRUE ,
  4126. TRUE ,
  4127. FALSE ,
  4128. FALSE ,
  4129. NULL,
  4130. NULL,
  4131. NULL ,
  4132. NULL
  4133. ) ;
  4134. t_Status = CheckValid(a_Range);
  4135. }
  4136. }
  4137. else if ( t_Value->GetType () == TypeId_WmiNullNode )
  4138. {
  4139. WmiNullNode *t_Null = ( WmiNullNode * ) t_Value ;
  4140. a_Range = new WmiNullRangeNode (
  4141. t_Null->GetPropertyName () ,
  4142. t_Null->GetIndex () ,
  4143. NULL ,
  4144. NULL
  4145. ) ;
  4146. t_Status = CheckValid(a_Range);
  4147. }
  4148. else
  4149. {
  4150. _DBG_ASSERT(FALSE);
  4151. }
  4152. }
  4153. return t_Status ;
  4154. }
  4155. /******************************************************************************
  4156. *
  4157. * Name:
  4158. *
  4159. *
  4160. * Description:
  4161. *
  4162. *
  4163. *****************************************************************************/
  4164. WmiTriState WmiOperatorEqualOrGreaterNode :: GetRange (WmiRangeNode *& a_Range)
  4165. {
  4166. WmiTriState t_Status = ::State_False;
  4167. a_Range = NULL ;
  4168. WmiTreeNode *t_Value = GetLeft () ;
  4169. if ( t_Value )
  4170. {
  4171. if ( t_Value->GetType () == TypeId_WmiUnsignedIntegerNode )
  4172. {
  4173. WmiUnsignedIntegerNode *t_Integer = ( WmiUnsignedIntegerNode * ) t_Value ;
  4174. a_Range = new WmiUnsignedIntegerRangeNode (
  4175. t_Integer->GetPropertyName () ,
  4176. t_Integer->GetIndex () ,
  4177. FALSE ,
  4178. TRUE ,
  4179. TRUE ,
  4180. FALSE ,
  4181. t_Integer->GetValue () ,
  4182. 0 ,
  4183. NULL ,
  4184. NULL
  4185. ) ;
  4186. t_Status = CheckValid(a_Range);
  4187. }
  4188. else if ( t_Value->GetType () == TypeId_WmiSignedIntegerNode )
  4189. {
  4190. WmiSignedIntegerNode *t_Integer = ( WmiSignedIntegerNode * ) t_Value ;
  4191. a_Range = new WmiSignedIntegerRangeNode (
  4192. t_Integer->GetPropertyName () ,
  4193. t_Integer->GetIndex () ,
  4194. FALSE ,
  4195. TRUE ,
  4196. TRUE ,
  4197. FALSE ,
  4198. t_Integer->GetValue () ,
  4199. 0 ,
  4200. NULL ,
  4201. NULL
  4202. ) ;
  4203. t_Status = CheckValid(a_Range);
  4204. }
  4205. else if ( t_Value->GetType () == TypeId_WmiStringNode )
  4206. {
  4207. WmiStringNode *t_String = ( WmiStringNode * ) t_Value ;
  4208. if ( t_String->GetPropertyFunction () == WmiValueNode :: WmiValueFunction :: Function_None )
  4209. {
  4210. a_Range = new WmiStringRangeNode (
  4211. t_String->GetPropertyName () ,
  4212. t_String->GetIndex () ,
  4213. FALSE ,
  4214. TRUE ,
  4215. TRUE ,
  4216. FALSE ,
  4217. t_String->GetValue () ,
  4218. NULL ,
  4219. NULL ,
  4220. NULL
  4221. ) ;
  4222. t_Status = CheckValid(a_Range);
  4223. }
  4224. else
  4225. {
  4226. a_Range = new WmiStringRangeNode (
  4227. t_String->GetPropertyName () ,
  4228. t_String->GetIndex () ,
  4229. TRUE ,
  4230. TRUE ,
  4231. FALSE ,
  4232. FALSE ,
  4233. NULL,
  4234. NULL,
  4235. NULL ,
  4236. NULL
  4237. ) ;
  4238. t_Status = CheckValid(a_Range);
  4239. }
  4240. }
  4241. else if ( t_Value->GetType () == TypeId_WmiNullNode )
  4242. {
  4243. WmiNullNode *t_Null = ( WmiNullNode * ) t_Value ;
  4244. a_Range = new WmiNullRangeNode (
  4245. t_Null->GetPropertyName () ,
  4246. t_Null->GetIndex () ,
  4247. NULL ,
  4248. NULL
  4249. ) ;
  4250. t_Status = CheckValid(a_Range);
  4251. }
  4252. else
  4253. {
  4254. _DBG_ASSERT(FALSE);
  4255. }
  4256. }
  4257. return t_Status ;
  4258. }
  4259. /******************************************************************************
  4260. *
  4261. * Name:
  4262. *
  4263. *
  4264. * Description:
  4265. *
  4266. *
  4267. *****************************************************************************/
  4268. WmiTriState WmiOperatorEqualOrLessNode :: GetRange (WmiRangeNode *& a_Range)
  4269. {
  4270. a_Range = NULL ;
  4271. WmiTriState t_Status = ::State_False;
  4272. WmiTreeNode *t_Value = GetLeft () ;
  4273. if ( t_Value )
  4274. {
  4275. if ( t_Value->GetType () == TypeId_WmiUnsignedIntegerNode )
  4276. {
  4277. WmiUnsignedIntegerNode *t_Integer = ( WmiUnsignedIntegerNode * ) t_Value ;
  4278. a_Range = new WmiUnsignedIntegerRangeNode (
  4279. t_Integer->GetPropertyName () ,
  4280. t_Integer->GetIndex () ,
  4281. TRUE ,
  4282. FALSE ,
  4283. FALSE ,
  4284. TRUE ,
  4285. 0 ,
  4286. t_Integer->GetValue () ,
  4287. NULL ,
  4288. NULL
  4289. ) ;
  4290. t_Status = CheckValid(a_Range);
  4291. }
  4292. else if ( t_Value->GetType () == TypeId_WmiSignedIntegerNode )
  4293. {
  4294. WmiSignedIntegerNode *t_Integer = ( WmiSignedIntegerNode * ) t_Value ;
  4295. a_Range = new WmiSignedIntegerRangeNode (
  4296. t_Integer->GetPropertyName () ,
  4297. t_Integer->GetIndex () ,
  4298. TRUE ,
  4299. FALSE ,
  4300. FALSE ,
  4301. TRUE ,
  4302. 0 ,
  4303. t_Integer->GetValue () ,
  4304. NULL ,
  4305. NULL
  4306. ) ;
  4307. t_Status = CheckValid(a_Range);
  4308. }
  4309. else if ( t_Value->GetType () == TypeId_WmiStringNode )
  4310. {
  4311. WmiStringNode *t_String = ( WmiStringNode * ) t_Value ;
  4312. if ( t_String->GetPropertyFunction () == WmiValueNode :: WmiValueFunction :: Function_None )
  4313. {
  4314. a_Range = new WmiStringRangeNode (
  4315. t_String->GetPropertyName () ,
  4316. t_String->GetIndex () ,
  4317. TRUE ,
  4318. FALSE ,
  4319. FALSE ,
  4320. TRUE ,
  4321. NULL ,
  4322. t_String->GetValue () ,
  4323. NULL ,
  4324. NULL
  4325. ) ;
  4326. t_Status = CheckValid(a_Range);
  4327. }
  4328. else
  4329. {
  4330. a_Range = new WmiStringRangeNode (
  4331. t_String->GetPropertyName () ,
  4332. t_String->GetIndex () ,
  4333. TRUE ,
  4334. TRUE ,
  4335. FALSE ,
  4336. FALSE ,
  4337. NULL,
  4338. NULL,
  4339. NULL ,
  4340. NULL
  4341. ) ;
  4342. t_Status = CheckValid(a_Range);
  4343. }
  4344. }
  4345. else if ( t_Value->GetType () == TypeId_WmiNullNode )
  4346. {
  4347. WmiNullNode *t_Null = ( WmiNullNode * ) t_Value ;
  4348. a_Range = new WmiNullRangeNode (
  4349. t_Null->GetPropertyName () ,
  4350. t_Null->GetIndex () ,
  4351. NULL ,
  4352. NULL
  4353. ) ;
  4354. t_Status = CheckValid(a_Range);
  4355. }
  4356. else
  4357. {
  4358. _DBG_ASSERT(FALSE);
  4359. }
  4360. }
  4361. return t_Status ;
  4362. }
  4363. /******************************************************************************
  4364. *
  4365. * Name:
  4366. *
  4367. *
  4368. * Description:
  4369. *
  4370. *
  4371. *****************************************************************************/
  4372. WmiTriState WmiOperatorLessNode :: GetRange (WmiRangeNode *& a_Range)
  4373. {
  4374. WmiTriState t_Status = ::State_False;
  4375. a_Range = NULL ;
  4376. WmiTreeNode *t_Value = GetLeft () ;
  4377. if ( t_Value )
  4378. {
  4379. if ( t_Value->GetType () == TypeId_WmiUnsignedIntegerNode )
  4380. {
  4381. WmiUnsignedIntegerNode *t_Integer = ( WmiUnsignedIntegerNode * ) t_Value ;
  4382. a_Range = new WmiUnsignedIntegerRangeNode (
  4383. t_Integer->GetPropertyName () ,
  4384. t_Integer->GetIndex () ,
  4385. TRUE ,
  4386. FALSE ,
  4387. FALSE ,
  4388. FALSE ,
  4389. 0 ,
  4390. t_Integer->GetValue () ,
  4391. NULL ,
  4392. NULL
  4393. ) ;
  4394. t_Status = CheckValid(a_Range);
  4395. }
  4396. else if ( t_Value->GetType () == TypeId_WmiSignedIntegerNode )
  4397. {
  4398. WmiSignedIntegerNode *t_Integer = ( WmiSignedIntegerNode * ) t_Value ;
  4399. a_Range = new WmiSignedIntegerRangeNode (
  4400. t_Integer->GetPropertyName () ,
  4401. t_Integer->GetIndex () ,
  4402. TRUE ,
  4403. FALSE ,
  4404. FALSE ,
  4405. FALSE ,
  4406. 0 ,
  4407. t_Integer->GetValue () ,
  4408. NULL ,
  4409. NULL
  4410. ) ;
  4411. t_Status = CheckValid(a_Range);
  4412. }
  4413. else if ( t_Value->GetType () == TypeId_WmiStringNode )
  4414. {
  4415. WmiStringNode *t_String = ( WmiStringNode * ) t_Value ;
  4416. if ( t_String->GetPropertyFunction () == WmiValueNode :: WmiValueFunction :: Function_None )
  4417. {
  4418. a_Range = new WmiStringRangeNode (
  4419. t_String->GetPropertyName () ,
  4420. t_String->GetIndex () ,
  4421. TRUE ,
  4422. FALSE ,
  4423. FALSE ,
  4424. FALSE ,
  4425. NULL ,
  4426. t_String->GetValue () ,
  4427. NULL ,
  4428. NULL
  4429. ) ;
  4430. t_Status = CheckValid(a_Range);
  4431. }
  4432. else
  4433. {
  4434. a_Range = new WmiStringRangeNode (
  4435. t_String->GetPropertyName () ,
  4436. t_String->GetIndex () ,
  4437. TRUE ,
  4438. TRUE ,
  4439. FALSE ,
  4440. FALSE ,
  4441. NULL,
  4442. NULL,
  4443. NULL ,
  4444. NULL
  4445. ) ;
  4446. t_Status = CheckValid(a_Range);
  4447. }
  4448. }
  4449. else if ( t_Value->GetType () == TypeId_WmiNullNode )
  4450. {
  4451. WmiNullNode *t_Null = ( WmiNullNode * ) t_Value ;
  4452. a_Range = new WmiNullRangeNode (
  4453. t_Null->GetPropertyName () ,
  4454. t_Null->GetIndex () ,
  4455. NULL ,
  4456. NULL
  4457. ) ;
  4458. t_Status = CheckValid(a_Range);
  4459. }
  4460. else
  4461. {
  4462. _DBG_ASSERT(FALSE);
  4463. }
  4464. }
  4465. return t_Status ;
  4466. }
  4467. /******************************************************************************
  4468. *
  4469. * Name:
  4470. *
  4471. *
  4472. * Description:
  4473. *
  4474. *
  4475. *****************************************************************************/
  4476. WmiTriState WmiOperatorGreaterNode :: GetRange (WmiRangeNode *& a_Range)
  4477. {
  4478. WmiTriState t_Status = ::State_False;
  4479. a_Range = NULL ;
  4480. WmiTreeNode *t_Value = GetLeft () ;
  4481. if ( t_Value )
  4482. {
  4483. if ( t_Value->GetType () == TypeId_WmiUnsignedIntegerNode )
  4484. {
  4485. WmiUnsignedIntegerNode *t_Integer = ( WmiUnsignedIntegerNode * ) t_Value ;
  4486. a_Range = new WmiUnsignedIntegerRangeNode (
  4487. t_Integer->GetPropertyName () ,
  4488. t_Integer->GetIndex () ,
  4489. FALSE ,
  4490. TRUE ,
  4491. FALSE ,
  4492. FALSE ,
  4493. t_Integer->GetValue () ,
  4494. 0 ,
  4495. NULL ,
  4496. NULL
  4497. ) ;
  4498. t_Status = CheckValid(a_Range);
  4499. }
  4500. else if ( t_Value->GetType () == TypeId_WmiSignedIntegerNode )
  4501. {
  4502. WmiSignedIntegerNode *t_Integer = ( WmiSignedIntegerNode * ) t_Value ;
  4503. a_Range = new WmiSignedIntegerRangeNode (
  4504. t_Integer->GetPropertyName () ,
  4505. t_Integer->GetIndex () ,
  4506. FALSE ,
  4507. TRUE ,
  4508. FALSE ,
  4509. FALSE ,
  4510. t_Integer->GetValue (),
  4511. 0 ,
  4512. NULL ,
  4513. NULL
  4514. ) ;
  4515. t_Status = CheckValid(a_Range);
  4516. }
  4517. else if ( t_Value->GetType () == TypeId_WmiStringNode )
  4518. {
  4519. WmiStringNode *t_String = ( WmiStringNode * ) t_Value ;
  4520. if ( t_String->GetPropertyFunction () == WmiValueNode :: WmiValueFunction :: Function_None )
  4521. {
  4522. a_Range = new WmiStringRangeNode (
  4523. t_String->GetPropertyName () ,
  4524. t_String->GetIndex () ,
  4525. FALSE ,
  4526. TRUE ,
  4527. FALSE ,
  4528. FALSE ,
  4529. t_String->GetValue () ,
  4530. NULL ,
  4531. NULL ,
  4532. NULL
  4533. ) ;
  4534. t_Status = CheckValid(a_Range);
  4535. }
  4536. else
  4537. {
  4538. a_Range = new WmiStringRangeNode (
  4539. t_String->GetPropertyName () ,
  4540. t_String->GetIndex () ,
  4541. TRUE ,
  4542. TRUE ,
  4543. FALSE ,
  4544. FALSE ,
  4545. NULL,
  4546. NULL,
  4547. NULL ,
  4548. NULL
  4549. ) ;
  4550. t_Status = CheckValid(a_Range);
  4551. }
  4552. }
  4553. else if ( t_Value->GetType () == TypeId_WmiNullNode )
  4554. {
  4555. WmiNullNode *t_Null = ( WmiNullNode * ) t_Value ;
  4556. a_Range = new WmiNullRangeNode (
  4557. t_Null->GetPropertyName () ,
  4558. t_Null->GetIndex () ,
  4559. NULL ,
  4560. NULL
  4561. ) ;
  4562. t_Status = CheckValid(a_Range);
  4563. }
  4564. else
  4565. {
  4566. _DBG_ASSERT(FALSE);
  4567. }
  4568. }
  4569. return t_Status ;
  4570. }
  4571. /******************************************************************************
  4572. *
  4573. * Name:
  4574. *
  4575. *
  4576. * Description:
  4577. *
  4578. *
  4579. *****************************************************************************/
  4580. WmiTriState WmiOperatorLikeNode :: GetRange (WmiRangeNode*& a_Range)
  4581. {
  4582. WmiTriState t_Status = ::State_False;
  4583. a_Range = NULL ;
  4584. WmiTreeNode *t_Value = GetLeft () ;
  4585. if ( t_Value )
  4586. {
  4587. if ( t_Value->GetType () == TypeId_WmiUnsignedIntegerNode )
  4588. {
  4589. }
  4590. else if ( t_Value->GetType () == TypeId_WmiSignedIntegerNode )
  4591. {
  4592. }
  4593. else if ( t_Value->GetType () == TypeId_WmiStringNode )
  4594. {
  4595. WmiStringNode *t_String = ( WmiStringNode * ) t_Value ;
  4596. if ( t_String->GetPropertyFunction () == WmiValueNode :: WmiValueFunction :: Function_None )
  4597. {
  4598. a_Range = new WmiStringRangeNode (
  4599. t_String->GetPropertyName () ,
  4600. t_String->GetIndex () ,
  4601. TRUE ,
  4602. TRUE ,
  4603. FALSE ,
  4604. FALSE ,
  4605. NULL ,
  4606. NULL ,
  4607. NULL ,
  4608. NULL
  4609. ) ;
  4610. t_Status = CheckValid(a_Range);
  4611. }
  4612. else
  4613. {
  4614. a_Range = new WmiStringRangeNode (
  4615. t_String->GetPropertyName () ,
  4616. t_String->GetIndex () ,
  4617. TRUE ,
  4618. TRUE ,
  4619. FALSE ,
  4620. FALSE ,
  4621. NULL ,
  4622. NULL ,
  4623. NULL ,
  4624. NULL
  4625. ) ;
  4626. t_Status = CheckValid(a_Range);
  4627. }
  4628. }
  4629. else if ( t_Value->GetType () == TypeId_WmiNullNode )
  4630. {
  4631. }
  4632. else
  4633. {
  4634. _DBG_ASSERT(FALSE);
  4635. }
  4636. }
  4637. return t_Status ;
  4638. }
  4639. /******************************************************************************
  4640. *
  4641. * Name:
  4642. *
  4643. *
  4644. * Description:
  4645. *
  4646. *
  4647. *****************************************************************************/
  4648. WmiTriState WmiOperatorNotLikeNode :: GetRange (WmiRangeNode*& a_Range)
  4649. {
  4650. WmiTriState t_Status = ::State_False;
  4651. a_Range = NULL ;
  4652. WmiTreeNode *t_Value = GetLeft () ;
  4653. if ( t_Value )
  4654. {
  4655. if ( t_Value->GetType () == TypeId_WmiUnsignedIntegerNode )
  4656. {
  4657. }
  4658. else if ( t_Value->GetType () == TypeId_WmiSignedIntegerNode )
  4659. {
  4660. }
  4661. else if ( t_Value->GetType () == TypeId_WmiStringNode )
  4662. {
  4663. WmiStringNode *t_String = ( WmiStringNode * ) t_Value ;
  4664. if ( t_String->GetPropertyFunction () == WmiValueNode :: WmiValueFunction :: Function_None )
  4665. {
  4666. a_Range = new WmiStringRangeNode (
  4667. t_String->GetPropertyName () ,
  4668. t_String->GetIndex () ,
  4669. TRUE ,
  4670. TRUE ,
  4671. FALSE ,
  4672. FALSE ,
  4673. NULL ,
  4674. NULL ,
  4675. NULL ,
  4676. NULL
  4677. ) ;
  4678. t_Status = CheckValid(a_Range);
  4679. }
  4680. else
  4681. {
  4682. a_Range = new WmiStringRangeNode (
  4683. t_String->GetPropertyName () ,
  4684. t_String->GetIndex () ,
  4685. TRUE ,
  4686. TRUE ,
  4687. FALSE ,
  4688. FALSE ,
  4689. NULL,
  4690. NULL,
  4691. NULL ,
  4692. NULL
  4693. ) ;
  4694. t_Status = CheckValid(a_Range);
  4695. }
  4696. }
  4697. else if ( t_Value->GetType () == TypeId_WmiNullNode )
  4698. {
  4699. }
  4700. else
  4701. {
  4702. _DBG_ASSERT(FALSE);
  4703. }
  4704. }
  4705. return t_Status ;
  4706. }
  4707. /******************************************************************************
  4708. *
  4709. * Name:
  4710. *
  4711. *
  4712. * Description:
  4713. *
  4714. *
  4715. *****************************************************************************/
  4716. WmiTriState WmiOperatorIsANode :: GetRange (WmiRangeNode*& a_Range)
  4717. {
  4718. WmiTriState t_Status = ::State_False;
  4719. a_Range = NULL ;
  4720. WmiTreeNode *t_Value = GetLeft () ;
  4721. if ( t_Value )
  4722. {
  4723. if ( t_Value->GetType () == TypeId_WmiUnsignedIntegerNode )
  4724. {
  4725. }
  4726. else if ( t_Value->GetType () == TypeId_WmiSignedIntegerNode )
  4727. {
  4728. }
  4729. else if ( t_Value->GetType () == TypeId_WmiStringNode )
  4730. {
  4731. WmiStringNode *t_String = ( WmiStringNode * ) t_Value ;
  4732. if ( t_String->GetPropertyFunction () == WmiValueNode :: WmiValueFunction :: Function_None )
  4733. {
  4734. a_Range = new WmiStringRangeNode (
  4735. t_String->GetPropertyName () ,
  4736. t_String->GetIndex () ,
  4737. TRUE ,
  4738. TRUE ,
  4739. FALSE ,
  4740. FALSE ,
  4741. NULL ,
  4742. NULL ,
  4743. NULL ,
  4744. NULL
  4745. ) ;
  4746. t_Status = CheckValid(a_Range);
  4747. }
  4748. else
  4749. {
  4750. a_Range = new WmiStringRangeNode (
  4751. t_String->GetPropertyName () ,
  4752. t_String->GetIndex () ,
  4753. TRUE ,
  4754. TRUE ,
  4755. FALSE ,
  4756. FALSE ,
  4757. NULL ,
  4758. NULL ,
  4759. NULL ,
  4760. NULL
  4761. ) ;
  4762. t_Status = CheckValid(a_Range);
  4763. }
  4764. }
  4765. else if ( t_Value->GetType () == TypeId_WmiNullNode )
  4766. {
  4767. }
  4768. else
  4769. {
  4770. _DBG_ASSERT(FALSE);
  4771. }
  4772. }
  4773. return t_Status ;
  4774. }
  4775. /******************************************************************************
  4776. *
  4777. * Name:
  4778. *
  4779. *
  4780. * Description:
  4781. *
  4782. *
  4783. *****************************************************************************/
  4784. WmiTriState WmiOperatorNotIsANode :: GetRange (WmiRangeNode*& a_Range )
  4785. {
  4786. WmiTriState t_Status = ::State_False;
  4787. a_Range = NULL ;
  4788. WmiTreeNode *t_Value = GetLeft () ;
  4789. if ( t_Value )
  4790. {
  4791. if ( t_Value->GetType () == TypeId_WmiUnsignedIntegerNode )
  4792. {
  4793. }
  4794. else if ( t_Value->GetType () == TypeId_WmiSignedIntegerNode )
  4795. {
  4796. }
  4797. else if ( t_Value->GetType () == TypeId_WmiStringNode )
  4798. {
  4799. WmiStringNode *t_String = ( WmiStringNode * ) t_Value ;
  4800. if ( t_String->GetPropertyFunction () == WmiValueNode :: WmiValueFunction :: Function_None )
  4801. {
  4802. a_Range = new WmiStringRangeNode (
  4803. t_String->GetPropertyName () ,
  4804. t_String->GetIndex () ,
  4805. TRUE ,
  4806. TRUE ,
  4807. FALSE ,
  4808. FALSE ,
  4809. NULL ,
  4810. NULL ,
  4811. NULL ,
  4812. NULL
  4813. ) ;
  4814. t_Status = CheckValid(a_Range);
  4815. }
  4816. else
  4817. {
  4818. a_Range = new WmiStringRangeNode (
  4819. t_String->GetPropertyName () ,
  4820. t_String->GetIndex () ,
  4821. TRUE ,
  4822. TRUE ,
  4823. FALSE ,
  4824. FALSE ,
  4825. NULL ,
  4826. NULL ,
  4827. NULL ,
  4828. NULL
  4829. ) ;
  4830. t_Status = CheckValid(a_Range);
  4831. }
  4832. }
  4833. else if ( t_Value->GetType () == TypeId_WmiNullNode )
  4834. {
  4835. }
  4836. else
  4837. {
  4838. _DBG_ASSERT(FALSE);
  4839. }
  4840. }
  4841. return t_Status ;
  4842. }
  4843. /******************************************************************************
  4844. *
  4845. * Name:
  4846. *
  4847. *
  4848. * Description:
  4849. *
  4850. *
  4851. *****************************************************************************/
  4852. BOOL QueryPreprocessor :: RecursiveEvaluate (
  4853. void *a_Context ,
  4854. SWbemRpnQueryToken **a_Expression ,
  4855. WmiTreeNode *a_Parent ,
  4856. WmiTreeNode **a_Node ,
  4857. int &a_Index
  4858. )
  4859. {
  4860. DebugMacro3(
  4861. WmiDebugLog :: s_WmiDebugLog->Write (
  4862. L"RecursiveEvaluate ( int &a_Index )"
  4863. ) ;
  4864. )
  4865. BOOL t_Status = TRUE ;
  4866. SWbemRpnQueryToken *t_Token = a_Expression [ a_Index ] ;
  4867. a_Index -- ;
  4868. switch ( t_Token->m_uTokenType )
  4869. {
  4870. case WMIQ_RPN_TOKEN_EXPRESSION:
  4871. {
  4872. DebugMacro3(
  4873. WmiDebugLog :: s_WmiDebugLog->Write (
  4874. L"Operation = OP_EXPESSION"
  4875. ) ;
  4876. )
  4877. WmiTreeNode *t_ParentNode = a_Parent ;
  4878. WmiTreeNode **t_Node = a_Node ;
  4879. WmiTreeNode *t_OperatorNode = NULL ;
  4880. if ( t_Token->m_uSubexpressionShape & WMIQ_RPN_RELOP )
  4881. {
  4882. switch ( t_Token->m_uOperator )
  4883. {
  4884. case WMIQ_RPN_OP_EQ:
  4885. {
  4886. t_OperatorNode = new WmiOperatorEqualNode ( NULL , t_ParentNode ) ;
  4887. }
  4888. break ;
  4889. case WMIQ_RPN_OP_NE:
  4890. {
  4891. t_OperatorNode = new WmiOperatorNotEqualNode ( NULL , t_ParentNode ) ;
  4892. }
  4893. break ;
  4894. case WMIQ_RPN_OP_GE:
  4895. {
  4896. t_OperatorNode = new WmiOperatorEqualOrGreaterNode ( NULL , t_ParentNode ) ;
  4897. }
  4898. break ;
  4899. case WMIQ_RPN_OP_LE:
  4900. {
  4901. t_OperatorNode = new WmiOperatorEqualOrLessNode ( NULL , t_ParentNode ) ;
  4902. }
  4903. break ;
  4904. case WMIQ_RPN_OP_LT:
  4905. {
  4906. t_OperatorNode = new WmiOperatorLessNode ( NULL , t_ParentNode ) ;
  4907. }
  4908. break ;
  4909. case WMIQ_RPN_OP_GT:
  4910. {
  4911. t_OperatorNode = new WmiOperatorGreaterNode ( NULL , t_ParentNode ) ;
  4912. }
  4913. break ;
  4914. case WMIQ_RPN_OP_LIKE:
  4915. {
  4916. t_OperatorNode = new WmiOperatorLikeNode ( NULL , t_ParentNode ) ;
  4917. }
  4918. break ;
  4919. case WMIQ_RPN_OP_ISA:
  4920. {
  4921. t_OperatorNode = new WmiOperatorIsANode ( NULL , t_ParentNode ) ;
  4922. }
  4923. break ;
  4924. default:
  4925. {
  4926. t_Status = FALSE ;
  4927. }
  4928. break ;
  4929. }
  4930. if ( t_OperatorNode == NULL )
  4931. {
  4932. t_Status = FALSE ;
  4933. }
  4934. }
  4935. else
  4936. {
  4937. t_Status = FALSE ;
  4938. }
  4939. if ( t_Status )
  4940. {
  4941. *t_Node = t_OperatorNode ;
  4942. t_ParentNode = t_OperatorNode ;
  4943. (*t_Node)->GetLeft ( t_Node ) ;
  4944. t_Status = TRUE ;
  4945. WmiValueNode :: WmiValueFunction t_PropertyFunction = WmiValueNode :: WmiValueFunction :: Function_None ;
  4946. if ( t_Token->m_uSubexpressionShape & WMIQ_RPN_LEFT_FUNCTION )
  4947. {
  4948. if ( wbem_wcsicmp ( t_Token->m_pszLeftFunc , L"Upper" ) == 0 )
  4949. {
  4950. t_PropertyFunction = WmiValueNode :: WmiValueFunction :: Function_Upper ;
  4951. }
  4952. else if ( wbem_wcsicmp ( t_Token->m_pszLeftFunc , L"Lower" ) == 0 )
  4953. {
  4954. t_PropertyFunction = WmiValueNode :: WmiValueFunction :: Function_Lower ;
  4955. }
  4956. else
  4957. {
  4958. t_Status = FALSE ;
  4959. }
  4960. }
  4961. WmiValueNode :: WmiValueFunction t_ConstantFunction = WmiValueNode :: WmiValueFunction :: Function_None ;
  4962. if ( t_Token->m_uSubexpressionShape & WMIQ_RPN_RIGHT_FUNCTION )
  4963. {
  4964. if ( wbem_wcsicmp ( t_Token->m_pszRightFunc , L"Upper" ) == 0 )
  4965. {
  4966. t_ConstantFunction = WmiValueNode :: WmiValueFunction :: Function_Upper ;
  4967. }
  4968. else if ( wbem_wcsicmp ( t_Token->m_pszRightFunc , L"Lower" ) == 0 )
  4969. {
  4970. t_ConstantFunction = WmiValueNode :: WmiValueFunction :: Function_Lower ;
  4971. }
  4972. else
  4973. {
  4974. t_Status = FALSE ;
  4975. }
  4976. }
  4977. if ( t_Status )
  4978. {
  4979. BOOL t_LeftProperty = t_Token->m_uSubexpressionShape & WMIQ_RPN_LEFT_PROPERTY_NAME ;
  4980. BOOL t_RightProperty = t_Token->m_uSubexpressionShape & WMIQ_RPN_RIGHT_PROPERTY_NAME ;
  4981. BOOL t_Const = t_Token->m_uSubexpressionShape & WMIQ_RPN_CONST ;
  4982. BOOL t_Const2 = t_Token->m_uSubexpressionShape & WMIQ_RPN_CONST2 ;
  4983. BOOL t_Validity = ( t_LeftProperty != 0 ) ? TRUE : FALSE ;
  4984. t_Validity = t_Validity && ( ( t_RightProperty != 0 ) ? FALSE : TRUE ) ;
  4985. t_Validity = t_Validity && ( ( t_Const != 0 ) ? TRUE : FALSE ) ;
  4986. t_Validity = t_Validity && ( ( t_Const2 != 0 ) ? FALSE : TRUE ) ;
  4987. if ( t_Validity )
  4988. {
  4989. VARIANT t_Variant ;
  4990. VariantInit ( & t_Variant ) ;
  4991. switch ( t_Token->m_uConstApparentType )
  4992. {
  4993. case VT_I8:
  4994. {
  4995. t_Variant.vt = VT_R8 ;
  4996. t_Variant.dblVal = t_Token->m_Const.m_dblVal ;
  4997. }
  4998. break ;
  4999. case VT_I4:
  5000. {
  5001. t_Variant.vt = VT_I4 ;
  5002. t_Variant.lVal = t_Token->m_Const.m_lLongVal ;
  5003. }
  5004. break ;
  5005. case VT_LPWSTR:
  5006. {
  5007. t_Variant.vt = VT_BSTR ;
  5008. t_Variant.bstrVal = SysAllocString ( t_Token->m_Const.m_pszStrVal ) ;
  5009. }
  5010. break ;
  5011. case CIM_EMPTY:
  5012. {
  5013. t_Variant.vt = VT_NULL ;
  5014. }
  5015. break ;
  5016. }
  5017. BSTR t_PropertyName = SysAllocString ( t_Token->m_pLeftIdent->m_ppszNameList [ 0 ] ) ;
  5018. if ( t_PropertyName )
  5019. {
  5020. WmiTreeNode *t_ValueNode = AllocTypeNode (
  5021. a_Context ,
  5022. t_PropertyName ,
  5023. t_Variant ,
  5024. t_PropertyFunction ,
  5025. t_ConstantFunction ,
  5026. t_ParentNode
  5027. ) ;
  5028. if ( t_ValueNode )
  5029. {
  5030. *t_Node = t_ValueNode ;
  5031. t_Status = TRUE ;
  5032. }
  5033. else
  5034. {
  5035. t_Status = FALSE ;
  5036. }
  5037. SysFreeString ( t_PropertyName ) ;
  5038. }
  5039. else
  5040. {
  5041. t_Status = FALSE ;
  5042. }
  5043. VariantClear ( & t_Variant ) ;
  5044. }
  5045. else
  5046. {
  5047. t_Status = FALSE ;
  5048. }
  5049. }
  5050. }
  5051. }
  5052. break ;
  5053. case WMIQ_RPN_TOKEN_AND:
  5054. {
  5055. *a_Node = new WmiAndNode ( NULL , NULL , a_Parent ) ;
  5056. if ( *a_Node )
  5057. {
  5058. WmiTreeNode **t_Left = NULL ;
  5059. WmiTreeNode **t_Right = NULL ;
  5060. (*a_Node)->GetLeft ( t_Left ) ;
  5061. (*a_Node)->GetRight ( t_Right ) ;
  5062. t_Status = RecursiveEvaluate ( a_Context , a_Expression , *a_Node , t_Left , a_Index ) &&
  5063. RecursiveEvaluate ( a_Context , a_Expression , *a_Node , t_Right , a_Index ) ;
  5064. }
  5065. else
  5066. {
  5067. t_Status = FALSE ;
  5068. }
  5069. DebugMacro3(
  5070. WmiDebugLog :: s_WmiDebugLog->Write (
  5071. L"Operation = TOKEN_AND"
  5072. ) ;
  5073. )
  5074. }
  5075. break ;
  5076. case WMIQ_RPN_TOKEN_OR:
  5077. {
  5078. *a_Node = new WmiOrNode ( NULL , NULL , a_Parent ) ;
  5079. if ( *a_Node )
  5080. {
  5081. WmiTreeNode **t_Left = NULL ;
  5082. WmiTreeNode **t_Right = NULL ;
  5083. (*a_Node)->GetLeft ( t_Left ) ;
  5084. (*a_Node)->GetRight ( t_Right ) ;
  5085. t_Status = RecursiveEvaluate ( a_Context , a_Expression , *a_Node , t_Left , a_Index ) &&
  5086. RecursiveEvaluate ( a_Context , a_Expression , *a_Node , t_Right , a_Index ) ;
  5087. }
  5088. else
  5089. {
  5090. t_Status = FALSE ;
  5091. }
  5092. DebugMacro3(
  5093. WmiDebugLog :: s_WmiDebugLog->Write (
  5094. L"Operation = TOKEN_OR"
  5095. ) ;
  5096. )
  5097. }
  5098. break ;
  5099. case WMIQ_RPN_TOKEN_NOT:
  5100. {
  5101. *a_Node = new WmiNotNode ( NULL , a_Parent ) ;
  5102. if ( *a_Node )
  5103. {
  5104. WmiTreeNode **t_Left = NULL ;
  5105. (*a_Node)->GetLeft ( t_Left ) ;
  5106. t_Status = RecursiveEvaluate ( a_Context , a_Expression , *a_Node , t_Left , a_Index ) ;
  5107. }
  5108. else
  5109. {
  5110. t_Status = FALSE ;
  5111. }
  5112. DebugMacro3(
  5113. WmiDebugLog :: s_WmiDebugLog->Write (
  5114. L"Operation = TOKEN_NOT"
  5115. ) ;
  5116. )
  5117. }
  5118. break ;
  5119. }
  5120. DebugMacro3(
  5121. WmiDebugLog :: s_WmiDebugLog->Write (
  5122. L"RecursiveEvaluation t_Status = (%lu)" ,
  5123. ( ULONG ) t_Status
  5124. ) ;
  5125. )
  5126. return t_Status ;
  5127. }
  5128. /******************************************************************************
  5129. *
  5130. * Name:
  5131. *
  5132. *
  5133. * Description:
  5134. *
  5135. *
  5136. *****************************************************************************/
  5137. BOOL QueryPreprocessor :: Evaluate (
  5138. void *a_Context ,
  5139. SWbemRpnQueryToken **a_Expression ,
  5140. int a_Count ,
  5141. WmiTreeNode **a_Root
  5142. )
  5143. {
  5144. BOOL t_Status = TRUE ;
  5145. if ( a_Count )
  5146. {
  5147. int t_Index = a_Count - 1 ; ;
  5148. t_Status = RecursiveEvaluate ( a_Context , a_Expression , NULL , a_Root , t_Index ) ;
  5149. }
  5150. DebugMacro3(
  5151. WmiDebugLog :: s_WmiDebugLog->Write (
  5152. L"PostEvaluation Status = (%lu)\n" ,
  5153. ( ULONG ) t_Status
  5154. ) ;
  5155. )
  5156. return t_Status ;
  5157. }
  5158. /******************************************************************************
  5159. *
  5160. * Name:
  5161. *
  5162. *
  5163. * Description:
  5164. *
  5165. *
  5166. *****************************************************************************/
  5167. void QueryPreprocessor :: PrintTree ( WmiTreeNode *a_Root )
  5168. {
  5169. DebugMacro3(
  5170. WmiDebugLog :: s_WmiDebugLog->Write (
  5171. L"Expression = "
  5172. ) ;
  5173. if ( a_Root )
  5174. a_Root->Print () ;
  5175. WmiDebugLog :: s_WmiDebugLog->Write (
  5176. L"\n"
  5177. ) ;
  5178. )
  5179. }
  5180. /******************************************************************************
  5181. *
  5182. * Name:
  5183. *
  5184. *
  5185. * Description:
  5186. *
  5187. *
  5188. *****************************************************************************/
  5189. void QueryPreprocessor :: TransformAndOrExpression (
  5190. WmiTreeNode *&a_Node ,
  5191. WmiTreeNode *a_AndChild ,
  5192. WmiTreeNode *a_OrChild
  5193. )
  5194. {
  5195. WmiTriState t_Status = :: State_True ;
  5196. WmiTreeNode *t_OrLeftChild = a_OrChild->GetLeft () ;
  5197. WmiTreeNode *t_OrRightChild = a_OrChild->GetRight () ;
  5198. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5199. WmiTreeNode *t_NewOrNode = new WmiOrNode ( NULL , NULL , t_Parent ) ;
  5200. if ( t_NewOrNode )
  5201. {
  5202. WmiTreeNode *t_NewOrNodeLeft = new WmiAndNode ( a_AndChild , t_OrLeftChild , t_NewOrNode ) ;
  5203. if ( t_NewOrNodeLeft )
  5204. {
  5205. t_NewOrNode->SetLeft ( t_NewOrNodeLeft ) ;
  5206. }
  5207. else
  5208. {
  5209. t_Status = :: State_Error ;
  5210. }
  5211. WmiTreeNode *t_AndChildCopy = a_AndChild->Copy () ;
  5212. if ( t_AndChildCopy )
  5213. {
  5214. WmiTreeNode *t_NewOrNodeRight = new WmiAndNode ( t_AndChildCopy , t_OrRightChild , t_NewOrNode ) ;
  5215. if ( t_NewOrNodeRight )
  5216. {
  5217. t_NewOrNode->SetRight ( t_NewOrNodeRight ) ;
  5218. }
  5219. else
  5220. {
  5221. t_Status = :: State_Error ;
  5222. }
  5223. }
  5224. else
  5225. {
  5226. t_Status = :: State_Error ;
  5227. }
  5228. if ( t_Parent )
  5229. {
  5230. if ( t_Parent->GetLeft () == a_Node )
  5231. {
  5232. t_Parent->SetLeft ( t_NewOrNode ) ;
  5233. }
  5234. else
  5235. {
  5236. t_Parent->SetRight ( t_NewOrNode ) ;
  5237. }
  5238. }
  5239. a_Node->SetLeft ( NULL ) ;
  5240. a_Node->SetRight ( NULL ) ;
  5241. a_Node->SetData ( NULL ) ;
  5242. a_OrChild->SetLeft ( NULL ) ;
  5243. a_OrChild->SetRight ( NULL ) ;
  5244. a_OrChild->SetData ( NULL ) ;
  5245. delete a_Node ;
  5246. a_Node = NULL ;
  5247. delete a_OrChild ;
  5248. a_OrChild = NULL ;
  5249. }
  5250. if ( t_Status == :: State_True )
  5251. {
  5252. a_Node = t_NewOrNode ;
  5253. }
  5254. else
  5255. {
  5256. delete t_NewOrNode ;
  5257. a_Node = NULL ;
  5258. }
  5259. }
  5260. /******************************************************************************
  5261. *
  5262. * Name:
  5263. *
  5264. *
  5265. * Description:
  5266. *
  5267. *
  5268. *****************************************************************************/
  5269. void QueryPreprocessor :: TransformNotNotExpression (
  5270. WmiTreeNode *&a_Node ,
  5271. WmiTreeNode *a_Child
  5272. )
  5273. {
  5274. WmiTreeNode *t_Leaf = a_Child->GetLeft () ;
  5275. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5276. t_Leaf->SetParent ( t_Parent ) ;
  5277. if ( t_Parent )
  5278. {
  5279. if ( t_Parent->GetLeft () == a_Node )
  5280. {
  5281. t_Parent->SetLeft ( t_Leaf ) ;
  5282. }
  5283. else
  5284. {
  5285. t_Parent->SetRight ( t_Leaf ) ;
  5286. }
  5287. }
  5288. a_Node->SetLeft ( NULL ) ;
  5289. a_Node->SetRight ( NULL ) ;
  5290. a_Node->SetData ( NULL ) ;
  5291. a_Child->SetLeft ( NULL ) ;
  5292. a_Child->SetRight ( NULL ) ;
  5293. a_Child->SetData ( NULL ) ;
  5294. delete a_Node ;
  5295. a_Node = NULL ;
  5296. delete a_Child ;
  5297. a_Child = NULL ;
  5298. a_Node = t_Leaf ;
  5299. }
  5300. /******************************************************************************
  5301. *
  5302. * Name:
  5303. *
  5304. *
  5305. * Description:
  5306. *
  5307. *
  5308. *****************************************************************************/
  5309. void QueryPreprocessor :: TransformNotAndExpression (
  5310. WmiTreeNode *&a_Node ,
  5311. WmiTreeNode *a_Child
  5312. )
  5313. {
  5314. WmiTriState t_Status = :: State_True ;
  5315. WmiTreeNode *t_AndLeftChild = a_Child->GetLeft () ;
  5316. WmiTreeNode *t_AndRightChild = a_Child->GetRight () ;
  5317. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5318. WmiTreeNode *t_NewOrNode = new WmiOrNode ( NULL , NULL , t_Parent ) ;
  5319. if ( t_NewOrNode )
  5320. {
  5321. WmiTreeNode *t_LeftNot = new WmiNotNode ( t_AndLeftChild , t_NewOrNode ) ;
  5322. if ( t_LeftNot )
  5323. {
  5324. t_NewOrNode->SetLeft ( t_LeftNot ) ;
  5325. }
  5326. else
  5327. {
  5328. t_Status = :: State_Error ;
  5329. }
  5330. WmiTreeNode *t_RightNot = new WmiNotNode ( t_AndRightChild , t_NewOrNode ) ;
  5331. if ( t_RightNot )
  5332. {
  5333. t_NewOrNode->SetRight ( t_RightNot ) ;
  5334. }
  5335. else
  5336. {
  5337. t_Status = :: State_Error ;
  5338. }
  5339. }
  5340. if ( t_Parent )
  5341. {
  5342. if ( t_Parent->GetLeft () == a_Node )
  5343. {
  5344. t_Parent->SetLeft ( t_NewOrNode ) ;
  5345. }
  5346. else
  5347. {
  5348. t_Parent->SetRight ( t_NewOrNode ) ;
  5349. }
  5350. }
  5351. a_Node->SetLeft ( NULL ) ;
  5352. a_Node->SetRight ( NULL ) ;
  5353. a_Node->SetData ( NULL ) ;
  5354. a_Child->SetLeft ( NULL ) ;
  5355. a_Child->SetRight ( NULL ) ;
  5356. a_Child->SetData ( NULL ) ;
  5357. delete a_Node ;
  5358. a_Node = NULL ;
  5359. delete a_Child ;
  5360. a_Child = NULL ;
  5361. if ( t_Status == :: State_True )
  5362. {
  5363. a_Node = t_NewOrNode ;
  5364. }
  5365. else
  5366. {
  5367. delete t_NewOrNode ;
  5368. }
  5369. }
  5370. /******************************************************************************
  5371. *
  5372. * Name:
  5373. *
  5374. *
  5375. * Description:
  5376. *
  5377. *
  5378. *****************************************************************************/
  5379. void QueryPreprocessor :: TransformNotOrExpression (
  5380. WmiTreeNode *&a_Node ,
  5381. WmiTreeNode *a_Child
  5382. )
  5383. {
  5384. WmiTriState t_Status = :: State_True ;
  5385. WmiTreeNode *t_OrLeftChild = a_Child->GetLeft () ;
  5386. WmiTreeNode *t_OrRightChild = a_Child->GetRight () ;
  5387. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5388. WmiTreeNode *t_NewAndNode = new WmiAndNode ( NULL , NULL , t_Parent ) ;
  5389. if ( t_NewAndNode )
  5390. {
  5391. WmiTreeNode *t_LeftNot = new WmiNotNode ( t_OrLeftChild , t_NewAndNode ) ;
  5392. if ( t_LeftNot )
  5393. {
  5394. t_NewAndNode->SetLeft ( t_LeftNot ) ;
  5395. }
  5396. else
  5397. {
  5398. t_Status = :: State_Error ;
  5399. }
  5400. WmiTreeNode *t_RightNot = new WmiNotNode ( t_OrRightChild , t_NewAndNode ) ;
  5401. if ( t_RightNot )
  5402. {
  5403. t_NewAndNode->SetRight ( t_RightNot ) ;
  5404. }
  5405. else
  5406. {
  5407. t_Status = :: State_Error ;
  5408. }
  5409. }
  5410. if ( t_Parent )
  5411. {
  5412. if ( t_Parent->GetLeft () == a_Node )
  5413. {
  5414. t_Parent->SetLeft ( t_NewAndNode ) ;
  5415. }
  5416. else
  5417. {
  5418. t_Parent->SetRight ( t_NewAndNode ) ;
  5419. }
  5420. }
  5421. a_Node->SetLeft ( NULL ) ;
  5422. a_Node->SetRight ( NULL ) ;
  5423. a_Node->SetData ( NULL ) ;
  5424. a_Child->SetLeft ( NULL ) ;
  5425. a_Child->SetRight ( NULL ) ;
  5426. a_Child->SetData ( NULL ) ;
  5427. delete a_Node ;
  5428. a_Node = NULL ;
  5429. delete a_Child ;
  5430. a_Child = NULL ;
  5431. if ( t_Status == :: State_True )
  5432. {
  5433. a_Node = t_NewAndNode ;
  5434. }
  5435. else
  5436. {
  5437. delete t_NewAndNode ;
  5438. }
  5439. }
  5440. /******************************************************************************
  5441. *
  5442. * Name:
  5443. *
  5444. *
  5445. * Description:
  5446. *
  5447. *
  5448. *****************************************************************************/
  5449. void QueryPreprocessor :: TransformNotEqualExpression (
  5450. WmiTreeNode *&a_Node ,
  5451. WmiTreeNode *a_Child
  5452. )
  5453. {
  5454. WmiTriState t_Status = :: State_True ;
  5455. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5456. WmiTreeNode *t_NewOrNode = new WmiOrNode ( NULL , NULL , t_Parent ) ;
  5457. if ( t_NewOrNode )
  5458. {
  5459. WmiTreeNode *t_LessNode = new WmiOperatorLessNode ( a_Child , t_NewOrNode ) ;
  5460. if ( t_LessNode )
  5461. {
  5462. t_NewOrNode->SetLeft ( t_LessNode ) ;
  5463. }
  5464. else
  5465. {
  5466. t_Status = :: State_Error ;
  5467. }
  5468. WmiTreeNode *t_CopyGreaterChild = a_Child->Copy () ;
  5469. if ( t_CopyGreaterChild )
  5470. {
  5471. WmiTreeNode *t_GreatorNode = new WmiOperatorGreaterNode ( t_CopyGreaterChild , t_NewOrNode ) ;
  5472. if ( t_GreatorNode )
  5473. {
  5474. t_NewOrNode->SetRight ( t_GreatorNode ) ;
  5475. }
  5476. else
  5477. {
  5478. t_Status = :: State_Error ;
  5479. }
  5480. }
  5481. else
  5482. {
  5483. t_Status = :: State_Error ;
  5484. }
  5485. }
  5486. if ( t_Parent )
  5487. {
  5488. if ( t_Parent->GetLeft () == a_Node )
  5489. {
  5490. t_Parent->SetLeft ( t_NewOrNode ) ;
  5491. }
  5492. else
  5493. {
  5494. t_Parent->SetRight ( t_NewOrNode ) ;
  5495. }
  5496. }
  5497. a_Node->SetLeft ( NULL ) ;
  5498. a_Node->SetRight ( NULL ) ;
  5499. a_Node->SetData ( NULL ) ;
  5500. delete a_Node ;
  5501. if ( t_Status == :: State_True )
  5502. {
  5503. a_Node = t_NewOrNode ;
  5504. }
  5505. else
  5506. {
  5507. delete t_NewOrNode ;
  5508. }
  5509. }
  5510. /******************************************************************************
  5511. *
  5512. * Name:
  5513. *
  5514. *
  5515. * Description:
  5516. *
  5517. *
  5518. *****************************************************************************/
  5519. void QueryPreprocessor :: TransformNotOperatorEqualExpression (
  5520. WmiTreeNode *&a_Node ,
  5521. WmiTreeNode *a_Child
  5522. )
  5523. {
  5524. WmiTriState t_Status = :: State_True ;
  5525. WmiTreeNode *t_Leaf = a_Child->GetLeft () ;
  5526. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5527. WmiTreeNode *t_NewNode = new WmiOperatorNotEqualNode ( t_Leaf , t_Parent ) ;
  5528. if ( ! t_NewNode )
  5529. {
  5530. t_Status = :: State_Error ;
  5531. }
  5532. if ( t_Parent )
  5533. {
  5534. if ( t_Parent->GetLeft () == a_Node )
  5535. {
  5536. t_Parent->SetLeft ( t_NewNode ) ;
  5537. }
  5538. else
  5539. {
  5540. t_Parent->SetRight ( t_NewNode ) ;
  5541. }
  5542. }
  5543. a_Child->SetLeft ( NULL ) ;
  5544. a_Child->SetRight ( NULL ) ;
  5545. a_Child->SetData ( NULL ) ;
  5546. delete a_Node ;
  5547. if ( t_Status == :: State_True )
  5548. {
  5549. a_Node = t_NewNode ;
  5550. }
  5551. else
  5552. {
  5553. delete t_NewNode ;
  5554. }
  5555. }
  5556. /******************************************************************************
  5557. *
  5558. * Name:
  5559. *
  5560. *
  5561. * Description:
  5562. *
  5563. *
  5564. *****************************************************************************/
  5565. void QueryPreprocessor :: TransformNotOperatorNotEqualExpression (
  5566. WmiTreeNode *&a_Node ,
  5567. WmiTreeNode *a_Child
  5568. )
  5569. {
  5570. WmiTriState t_Status = :: State_True ;
  5571. WmiTreeNode *t_Leaf = a_Child->GetLeft () ;
  5572. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5573. WmiTreeNode *t_NewNode = new WmiOperatorEqualNode ( t_Leaf , t_Parent ) ;
  5574. if ( ! t_NewNode )
  5575. {
  5576. t_Status = :: State_Error ;
  5577. }
  5578. if ( t_Parent )
  5579. {
  5580. if ( t_Parent->GetLeft () == a_Node )
  5581. {
  5582. t_Parent->SetLeft ( t_NewNode ) ;
  5583. }
  5584. else
  5585. {
  5586. t_Parent->SetRight ( t_NewNode ) ;
  5587. }
  5588. }
  5589. a_Child->SetLeft ( NULL ) ;
  5590. a_Child->SetRight ( NULL ) ;
  5591. a_Child->SetData ( NULL ) ;
  5592. delete a_Node ;
  5593. if ( t_Status == :: State_True )
  5594. {
  5595. a_Node = t_NewNode ;
  5596. }
  5597. else
  5598. {
  5599. delete t_NewNode ;
  5600. }
  5601. }
  5602. /******************************************************************************
  5603. *
  5604. * Name:
  5605. *
  5606. *
  5607. * Description:
  5608. *
  5609. *
  5610. *****************************************************************************/
  5611. void QueryPreprocessor :: TransformNotOperatorEqualOrGreaterExpression (
  5612. WmiTreeNode *&a_Node ,
  5613. WmiTreeNode *a_Child
  5614. )
  5615. {
  5616. WmiTriState t_Status = :: State_True ;
  5617. WmiTreeNode *t_Leaf = a_Child->GetLeft () ;
  5618. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5619. WmiTreeNode *t_NewNode = new WmiOperatorEqualOrLessNode ( t_Leaf , t_Parent ) ;
  5620. if ( ! t_NewNode )
  5621. {
  5622. t_Status = :: State_Error ;
  5623. }
  5624. if ( t_Parent )
  5625. {
  5626. if ( t_Parent->GetLeft () == a_Node )
  5627. {
  5628. t_Parent->SetLeft ( t_NewNode ) ;
  5629. }
  5630. else
  5631. {
  5632. t_Parent->SetRight ( t_NewNode ) ;
  5633. }
  5634. }
  5635. a_Child->SetLeft ( NULL ) ;
  5636. a_Child->SetRight ( NULL ) ;
  5637. a_Child->SetData ( NULL ) ;
  5638. delete a_Node ;
  5639. if ( t_Status == :: State_True )
  5640. {
  5641. a_Node = t_NewNode ;
  5642. }
  5643. else
  5644. {
  5645. delete t_NewNode ;
  5646. }
  5647. }
  5648. /******************************************************************************
  5649. *
  5650. * Name:
  5651. *
  5652. *
  5653. * Description:
  5654. *
  5655. *
  5656. *****************************************************************************/
  5657. void QueryPreprocessor :: TransformNotOperatorEqualOrLessExpression (
  5658. WmiTreeNode *&a_Node ,
  5659. WmiTreeNode *a_Child
  5660. )
  5661. {
  5662. WmiTriState t_Status = :: State_True ;
  5663. WmiTreeNode *t_Leaf = a_Child->GetLeft () ;
  5664. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5665. WmiTreeNode *t_NewNode = new WmiOperatorEqualOrGreaterNode ( t_Leaf , t_Parent ) ;
  5666. if ( ! t_NewNode )
  5667. {
  5668. t_Status = :: State_Error ;
  5669. }
  5670. if ( t_Parent )
  5671. {
  5672. if ( t_Parent->GetLeft () == a_Node )
  5673. {
  5674. t_Parent->SetLeft ( t_NewNode ) ;
  5675. }
  5676. else
  5677. {
  5678. t_Parent->SetRight ( t_NewNode ) ;
  5679. }
  5680. }
  5681. a_Child->SetLeft ( NULL ) ;
  5682. a_Child->SetRight ( NULL ) ;
  5683. a_Child->SetData ( NULL ) ;
  5684. delete a_Node ;
  5685. if ( t_Status == :: State_True )
  5686. {
  5687. a_Node = t_NewNode ;
  5688. }
  5689. else
  5690. {
  5691. delete t_NewNode ;
  5692. }
  5693. }
  5694. /******************************************************************************
  5695. *
  5696. * Name:
  5697. *
  5698. *
  5699. * Description:
  5700. *
  5701. *
  5702. *****************************************************************************/
  5703. void QueryPreprocessor :: TransformNotOperatorGreaterExpression (
  5704. WmiTreeNode *&a_Node ,
  5705. WmiTreeNode *a_Child
  5706. )
  5707. {
  5708. WmiTriState t_Status = :: State_True ;
  5709. WmiTreeNode *t_Leaf = a_Child->GetLeft () ;
  5710. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5711. WmiTreeNode *t_NewNode = new WmiOperatorEqualOrLessNode ( t_Leaf , t_Parent ) ;
  5712. if ( ! t_NewNode )
  5713. {
  5714. t_Status = :: State_Error ;
  5715. }
  5716. if ( t_Parent )
  5717. {
  5718. if ( t_Parent->GetLeft () == a_Node )
  5719. {
  5720. t_Parent->SetLeft ( t_NewNode ) ;
  5721. }
  5722. else
  5723. {
  5724. t_Parent->SetRight ( t_NewNode ) ;
  5725. }
  5726. }
  5727. a_Child->SetLeft ( NULL ) ;
  5728. a_Child->SetRight ( NULL ) ;
  5729. a_Child->SetData ( NULL ) ;
  5730. delete a_Node ;
  5731. if ( t_Status == :: State_True )
  5732. {
  5733. a_Node = t_NewNode ;
  5734. }
  5735. else
  5736. {
  5737. delete t_NewNode ;
  5738. }
  5739. }
  5740. /******************************************************************************
  5741. *
  5742. * Name:
  5743. *
  5744. *
  5745. * Description:
  5746. *
  5747. *
  5748. *****************************************************************************/
  5749. void QueryPreprocessor :: TransformNotOperatorLessExpression (
  5750. WmiTreeNode *&a_Node ,
  5751. WmiTreeNode *a_Child
  5752. )
  5753. {
  5754. WmiTriState t_Status = :: State_True ;
  5755. WmiTreeNode *t_Leaf = a_Child->GetLeft () ;
  5756. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5757. WmiTreeNode *t_NewNode = new WmiOperatorEqualOrGreaterNode ( t_Leaf , t_Parent ) ;
  5758. if ( ! t_NewNode )
  5759. {
  5760. t_Status = :: State_Error ;
  5761. }
  5762. if ( t_Parent )
  5763. {
  5764. if ( t_Parent->GetLeft () == a_Node )
  5765. {
  5766. t_Parent->SetLeft ( t_NewNode ) ;
  5767. }
  5768. else
  5769. {
  5770. t_Parent->SetRight ( t_NewNode ) ;
  5771. }
  5772. }
  5773. a_Child->SetLeft ( NULL ) ;
  5774. a_Child->SetRight ( NULL ) ;
  5775. a_Child->SetData ( NULL ) ;
  5776. delete a_Node ;
  5777. if ( t_Status == :: State_True )
  5778. {
  5779. a_Node = t_NewNode ;
  5780. }
  5781. else
  5782. {
  5783. delete t_NewNode ;
  5784. }
  5785. }
  5786. /******************************************************************************
  5787. *
  5788. * Name:
  5789. *
  5790. *
  5791. * Description:
  5792. *
  5793. *
  5794. *****************************************************************************/
  5795. void QueryPreprocessor :: TransformNotOperatorLikeExpression (
  5796. WmiTreeNode *&a_Node ,
  5797. WmiTreeNode *a_Child
  5798. )
  5799. {
  5800. WmiTriState t_Status = :: State_True ;
  5801. WmiTreeNode *t_Leaf = a_Child->GetLeft () ;
  5802. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5803. WmiTreeNode *t_NewNode = new WmiOperatorNotLikeNode ( t_Leaf , t_Parent ) ;
  5804. if ( ! t_NewNode )
  5805. {
  5806. t_Status = :: State_Error ;
  5807. }
  5808. if ( t_Parent )
  5809. {
  5810. if ( t_Parent->GetLeft () == a_Node )
  5811. {
  5812. t_Parent->SetLeft ( t_NewNode ) ;
  5813. }
  5814. else
  5815. {
  5816. t_Parent->SetRight ( t_NewNode ) ;
  5817. }
  5818. }
  5819. a_Child->SetLeft ( NULL ) ;
  5820. a_Child->SetRight ( NULL ) ;
  5821. a_Child->SetData ( NULL ) ;
  5822. delete a_Node ;
  5823. if ( t_Status == :: State_True )
  5824. {
  5825. a_Node = t_NewNode ;
  5826. }
  5827. else
  5828. {
  5829. delete t_NewNode ;
  5830. }
  5831. }
  5832. /******************************************************************************
  5833. *
  5834. * Name:
  5835. *
  5836. *
  5837. * Description:
  5838. *
  5839. *
  5840. *****************************************************************************/
  5841. void QueryPreprocessor :: TransformNotOperatorNotLikeExpression (
  5842. WmiTreeNode *&a_Node ,
  5843. WmiTreeNode *a_Child
  5844. )
  5845. {
  5846. WmiTriState t_Status = :: State_True ;
  5847. WmiTreeNode *t_Leaf = a_Child->GetLeft () ;
  5848. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5849. WmiTreeNode *t_NewNode = new WmiOperatorLikeNode ( t_Leaf , t_Parent ) ;
  5850. if ( ! t_NewNode )
  5851. {
  5852. t_Status = :: State_Error ;
  5853. }
  5854. if ( t_Parent )
  5855. {
  5856. if ( t_Parent->GetLeft () == a_Node )
  5857. {
  5858. t_Parent->SetLeft ( t_NewNode ) ;
  5859. }
  5860. else
  5861. {
  5862. t_Parent->SetRight ( t_NewNode ) ;
  5863. }
  5864. }
  5865. a_Child->SetLeft ( NULL ) ;
  5866. a_Child->SetRight ( NULL ) ;
  5867. a_Child->SetData ( NULL ) ;
  5868. delete a_Node ;
  5869. if ( t_Status == :: State_True )
  5870. {
  5871. a_Node = t_NewNode ;
  5872. }
  5873. else
  5874. {
  5875. delete t_NewNode ;
  5876. }
  5877. }
  5878. /******************************************************************************
  5879. *
  5880. * Name:
  5881. *
  5882. *
  5883. * Description:
  5884. *
  5885. *
  5886. *****************************************************************************/
  5887. void QueryPreprocessor :: TransformNotOperatorIsAExpression (
  5888. WmiTreeNode *&a_Node ,
  5889. WmiTreeNode *a_Child
  5890. )
  5891. {
  5892. WmiTriState t_Status = :: State_True ;
  5893. WmiTreeNode *t_Leaf = a_Child->GetLeft () ;
  5894. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5895. WmiTreeNode *t_NewNode = new WmiOperatorNotIsANode ( t_Leaf , t_Parent ) ;
  5896. if ( ! t_NewNode )
  5897. {
  5898. t_Status = :: State_Error ;
  5899. }
  5900. if ( t_Parent )
  5901. {
  5902. if ( t_Parent->GetLeft () == a_Node )
  5903. {
  5904. t_Parent->SetLeft ( t_NewNode ) ;
  5905. }
  5906. else
  5907. {
  5908. t_Parent->SetRight ( t_NewNode ) ;
  5909. }
  5910. }
  5911. a_Child->SetLeft ( NULL ) ;
  5912. a_Child->SetRight ( NULL ) ;
  5913. a_Child->SetData ( NULL ) ;
  5914. delete a_Node ;
  5915. if ( t_Status == :: State_True )
  5916. {
  5917. a_Node = t_NewNode ;
  5918. }
  5919. else
  5920. {
  5921. delete t_NewNode ;
  5922. }
  5923. }
  5924. /******************************************************************************
  5925. *
  5926. * Name:
  5927. *
  5928. *
  5929. * Description:
  5930. *
  5931. *
  5932. *****************************************************************************/
  5933. void QueryPreprocessor :: TransformNotOperatorNotIsAExpression (
  5934. WmiTreeNode *&a_Node ,
  5935. WmiTreeNode *a_Child
  5936. )
  5937. {
  5938. WmiTriState t_Status = :: State_True ;
  5939. WmiTreeNode *t_Leaf = a_Child->GetLeft () ;
  5940. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5941. WmiTreeNode *t_NewNode = new WmiOperatorIsANode ( t_Leaf , t_Parent ) ;
  5942. if ( ! t_NewNode )
  5943. {
  5944. t_Status = :: State_Error ;
  5945. }
  5946. if ( t_Parent )
  5947. {
  5948. if ( t_Parent->GetLeft () == a_Node )
  5949. {
  5950. t_Parent->SetLeft ( t_NewNode ) ;
  5951. }
  5952. else
  5953. {
  5954. t_Parent->SetRight ( t_NewNode ) ;
  5955. }
  5956. }
  5957. a_Child->SetLeft ( NULL ) ;
  5958. a_Child->SetRight ( NULL ) ;
  5959. a_Child->SetData ( NULL ) ;
  5960. delete a_Node ;
  5961. if ( t_Status == :: State_True )
  5962. {
  5963. a_Node = t_NewNode ;
  5964. }
  5965. else
  5966. {
  5967. delete t_NewNode ;
  5968. }
  5969. }
  5970. /******************************************************************************
  5971. *
  5972. * Name:
  5973. *
  5974. *
  5975. * Description:
  5976. *
  5977. *
  5978. *****************************************************************************/
  5979. void QueryPreprocessor :: TransformAndTrueEvaluation (
  5980. WmiTreeNode *&a_Node ,
  5981. WmiTreeNode *a_Child
  5982. )
  5983. {
  5984. if ( a_Node->GetLeft () == a_Child )
  5985. {
  5986. a_Node->SetLeft ( NULL ) ;
  5987. }
  5988. else
  5989. {
  5990. a_Node->SetRight ( NULL ) ;
  5991. }
  5992. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  5993. if ( t_Parent )
  5994. {
  5995. if ( t_Parent->GetLeft () == a_Node )
  5996. {
  5997. t_Parent->SetLeft ( a_Child ) ;
  5998. }
  5999. else
  6000. {
  6001. t_Parent->SetRight ( a_Child ) ;
  6002. }
  6003. }
  6004. a_Child->SetParent ( t_Parent ) ;
  6005. delete a_Node ;
  6006. a_Node = a_Child ;
  6007. }
  6008. /******************************************************************************
  6009. *
  6010. * Name:
  6011. *
  6012. *
  6013. * Description:
  6014. *
  6015. *
  6016. *****************************************************************************/
  6017. void QueryPreprocessor :: TransformOrFalseEvaluation (
  6018. WmiTreeNode *&a_Node ,
  6019. WmiTreeNode *a_Child
  6020. )
  6021. {
  6022. if ( a_Node->GetLeft () == a_Child )
  6023. {
  6024. a_Node->SetLeft ( NULL ) ;
  6025. }
  6026. else
  6027. {
  6028. a_Node->SetRight ( NULL ) ;
  6029. }
  6030. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  6031. if ( t_Parent )
  6032. {
  6033. if ( t_Parent->GetLeft () == a_Node )
  6034. {
  6035. t_Parent->SetLeft ( a_Child ) ;
  6036. }
  6037. else
  6038. {
  6039. t_Parent->SetRight ( a_Child ) ;
  6040. }
  6041. }
  6042. a_Child->SetParent ( t_Parent ) ;
  6043. delete a_Node ;
  6044. a_Node = a_Child ;
  6045. }
  6046. /******************************************************************************
  6047. *
  6048. * Name:
  6049. *
  6050. *
  6051. * Description:
  6052. *
  6053. *
  6054. *****************************************************************************/
  6055. void QueryPreprocessor :: TransformOperatorToRange (
  6056. WmiTreeNode *&a_Node
  6057. )
  6058. {
  6059. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  6060. WmiOperatorNode *t_OperatorNode = ( WmiOperatorNode * ) a_Node ;
  6061. WmiRangeNode *t_Range = 0;
  6062. if (t_OperatorNode->GetRange (t_Range) == State_True && t_Range)
  6063. {
  6064. if ( t_Parent )
  6065. {
  6066. if ( t_Parent->GetLeft () == a_Node )
  6067. {
  6068. t_Parent->SetLeft ( t_Range ) ;
  6069. }
  6070. else
  6071. {
  6072. t_Parent->SetRight ( t_Range ) ;
  6073. }
  6074. }
  6075. t_Range->SetParent ( t_Parent ) ;
  6076. }
  6077. delete a_Node ;
  6078. a_Node = t_Range ;
  6079. }
  6080. /******************************************************************************
  6081. *
  6082. * Name:
  6083. *
  6084. *
  6085. * Description:
  6086. *
  6087. *
  6088. *****************************************************************************/
  6089. WmiTriState QueryPreprocessor :: EvaluateNotExpression ( WmiTreeNode *&a_Node )
  6090. {
  6091. if ( a_Node->GetLeft () )
  6092. {
  6093. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6094. if ( t_Left->GetType () == TypeId_WmiAndNode )
  6095. {
  6096. TransformNotAndExpression ( a_Node , t_Left ) ;
  6097. return a_Node ? :: State_True : :: State_Error ;
  6098. }
  6099. else if ( t_Left->GetType () == TypeId_WmiOrNode )
  6100. {
  6101. TransformNotOrExpression ( a_Node , t_Left ) ;
  6102. return a_Node ? :: State_True : :: State_Error ;
  6103. }
  6104. else if ( t_Left->GetType () == TypeId_WmiNotNode )
  6105. {
  6106. TransformNotNotExpression ( a_Node , t_Left ) ;
  6107. return a_Node ? :: State_True : :: State_Error ;
  6108. }
  6109. else if ( t_Left->GetType () == TypeId_WmiOperatorEqualNode )
  6110. {
  6111. TransformNotOperatorEqualExpression ( a_Node , t_Left ) ;
  6112. return a_Node ? :: State_True : :: State_Error ;
  6113. }
  6114. else if ( t_Left->GetType () == TypeId_WmiOperatorNotEqualNode )
  6115. {
  6116. TransformNotOperatorNotEqualExpression ( a_Node , t_Left ) ;
  6117. return a_Node ? :: State_True : :: State_Error ;
  6118. }
  6119. else if ( t_Left->GetType () == TypeId_WmiOperatorEqualOrGreaterNode )
  6120. {
  6121. TransformNotOperatorEqualOrGreaterExpression ( a_Node , t_Left ) ;
  6122. return a_Node ? :: State_True : :: State_Error ;
  6123. }
  6124. else if ( t_Left->GetType () == TypeId_WmiOperatorEqualOrLessNode )
  6125. {
  6126. TransformNotOperatorEqualOrLessExpression ( a_Node , t_Left ) ;
  6127. return a_Node ? :: State_True : :: State_Error ;
  6128. }
  6129. else if ( t_Left->GetType () == TypeId_WmiOperatorLessNode )
  6130. {
  6131. TransformNotOperatorLessExpression ( a_Node , t_Left ) ;
  6132. return a_Node ? :: State_True : :: State_Error ;
  6133. }
  6134. else if ( t_Left->GetType () == TypeId_WmiOperatorGreaterNode )
  6135. {
  6136. TransformNotOperatorGreaterExpression ( a_Node , t_Left ) ;
  6137. return a_Node ? :: State_True : :: State_Error ;
  6138. }
  6139. else if ( t_Left->GetType () == TypeId_WmiOperatorLikeNode )
  6140. {
  6141. TransformNotOperatorLikeExpression ( a_Node , t_Left ) ;
  6142. return a_Node ? :: State_True : :: State_Error ;
  6143. }
  6144. else if ( t_Left->GetType () == TypeId_WmiOperatorNotLikeNode )
  6145. {
  6146. TransformNotOperatorNotLikeExpression ( a_Node , t_Left ) ;
  6147. return a_Node ? :: State_True : :: State_Error ;
  6148. }
  6149. else if ( t_Left->GetType () == TypeId_WmiOperatorIsANode )
  6150. {
  6151. TransformNotOperatorIsAExpression ( a_Node , t_Left ) ;
  6152. return a_Node ? :: State_True : :: State_Error ;
  6153. }
  6154. else if ( t_Left->GetType () == TypeId_WmiOperatorNotIsANode )
  6155. {
  6156. TransformNotOperatorNotIsAExpression ( a_Node , t_Left ) ;
  6157. return a_Node ? :: State_True : :: State_Error ;
  6158. }
  6159. else
  6160. {
  6161. return :: State_False ;
  6162. }
  6163. }
  6164. return :: State_Error ;
  6165. }
  6166. /******************************************************************************
  6167. *
  6168. * Name:
  6169. *
  6170. *
  6171. * Description:
  6172. *
  6173. *
  6174. *****************************************************************************/
  6175. WmiTriState QueryPreprocessor :: EvaluateNotEqualExpression ( WmiTreeNode *&a_Node )
  6176. {
  6177. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6178. TransformNotEqualExpression ( a_Node , t_Left ) ;
  6179. return a_Node ? :: State_True : :: State_Error ;
  6180. }
  6181. /******************************************************************************
  6182. *
  6183. * Name:
  6184. *
  6185. *
  6186. * Description:
  6187. *
  6188. *
  6189. *****************************************************************************/
  6190. WmiTriState QueryPreprocessor :: EvaluateAndExpression ( WmiTreeNode *&a_Node )
  6191. {
  6192. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6193. WmiTreeNode *t_Right = a_Node->GetRight () ;
  6194. if ( t_Left )
  6195. {
  6196. if ( t_Left->GetType () == TypeId_WmiOrNode )
  6197. {
  6198. TransformAndOrExpression ( a_Node , t_Right , t_Left ) ;
  6199. return a_Node ? :: State_True : :: State_Error ;
  6200. }
  6201. }
  6202. if ( t_Right )
  6203. {
  6204. if ( t_Right->GetType () == TypeId_WmiOrNode )
  6205. {
  6206. TransformAndOrExpression ( a_Node , t_Left , t_Right ) ;
  6207. return a_Node ? :: State_True : :: State_Error ;
  6208. }
  6209. }
  6210. return :: State_False ;
  6211. }
  6212. /******************************************************************************
  6213. *
  6214. * Name:
  6215. *
  6216. *
  6217. * Description:
  6218. *
  6219. *
  6220. *****************************************************************************/
  6221. WmiTriState QueryPreprocessor :: EvaluateOrExpression ( WmiTreeNode *&a_Node )
  6222. {
  6223. return :: State_False ;
  6224. }
  6225. /******************************************************************************
  6226. *
  6227. * Name:
  6228. *
  6229. *
  6230. * Description:
  6231. *
  6232. *
  6233. *****************************************************************************/
  6234. QueryPreprocessor :: QuadState QueryPreprocessor :: RecursiveDisjunctiveNormalForm ( WmiTreeNode *&a_Node )
  6235. {
  6236. QueryPreprocessor :: QuadState t_Status = State_True ;
  6237. WmiTriState tStatus = :: State_Error;
  6238. if ( a_Node )
  6239. {
  6240. if ( a_Node->GetType () == TypeId_WmiAndNode )
  6241. {
  6242. if ( (tStatus = EvaluateAndExpression ( a_Node )) == :: State_True )
  6243. {
  6244. t_Status = QuadState :: State_ReEvaluate ;
  6245. }
  6246. else if (tStatus == :: State_Error)
  6247. {
  6248. t_Status = QuadState :: State_Error ;
  6249. }
  6250. else
  6251. {
  6252. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6253. WmiTreeNode *t_Right = a_Node->GetRight () ;
  6254. if ( t_Left )
  6255. {
  6256. t_Status = RecursiveDisjunctiveNormalForm ( t_Left ) ;
  6257. if ( t_Status == QuadState :: State_ReEvaluate )
  6258. {
  6259. t_Status = RecursiveDisjunctiveNormalForm ( a_Node ) ;
  6260. return t_Status ;
  6261. }
  6262. }
  6263. if ( t_Right )
  6264. {
  6265. t_Status = RecursiveDisjunctiveNormalForm ( t_Right ) ;
  6266. if ( t_Status == QuadState :: State_ReEvaluate )
  6267. {
  6268. t_Status = RecursiveDisjunctiveNormalForm ( a_Node ) ;
  6269. return t_Status ;
  6270. }
  6271. }
  6272. }
  6273. }
  6274. else if ( a_Node->GetType () == TypeId_WmiOrNode )
  6275. {
  6276. if ( EvaluateOrExpression ( a_Node ) == :: State_True )
  6277. {
  6278. t_Status = QuadState :: State_ReEvaluate ;
  6279. }
  6280. else
  6281. {
  6282. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6283. WmiTreeNode *t_Right = a_Node->GetRight () ;
  6284. if ( t_Left )
  6285. {
  6286. t_Status = RecursiveDisjunctiveNormalForm ( t_Left ) ;
  6287. if ( t_Status == QuadState :: State_ReEvaluate )
  6288. {
  6289. t_Status = RecursiveDisjunctiveNormalForm ( a_Node ) ;
  6290. return t_Status ;
  6291. }
  6292. }
  6293. if ( t_Right )
  6294. {
  6295. t_Status = RecursiveDisjunctiveNormalForm ( t_Right ) ;
  6296. if ( t_Status == QuadState :: State_ReEvaluate )
  6297. {
  6298. t_Status = RecursiveDisjunctiveNormalForm ( a_Node ) ;
  6299. return t_Status ;
  6300. }
  6301. }
  6302. }
  6303. }
  6304. else if ( a_Node->GetType () == TypeId_WmiNotNode )
  6305. {
  6306. if ( (tStatus = EvaluateNotExpression ( a_Node )) == :: State_True )
  6307. {
  6308. t_Status = QuadState :: State_ReEvaluate ;
  6309. }
  6310. else if (tStatus == ::State_Error)
  6311. {
  6312. t_Status = QuadState :: State_Error;
  6313. }
  6314. else
  6315. {
  6316. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6317. if ( t_Left )
  6318. {
  6319. t_Status = RecursiveDisjunctiveNormalForm ( t_Left ) ;
  6320. if ( t_Status == QuadState :: State_ReEvaluate )
  6321. {
  6322. t_Status = RecursiveDisjunctiveNormalForm ( a_Node ) ;
  6323. return t_Status ;
  6324. }
  6325. }
  6326. }
  6327. }
  6328. else if ( a_Node->GetType () == TypeId_WmiOperatorNotEqualNode )
  6329. {
  6330. if ( (tStatus = EvaluateNotEqualExpression ( a_Node )) == :: State_True )
  6331. {
  6332. t_Status = QuadState :: State_ReEvaluate ;
  6333. }
  6334. else if (tStatus == ::State_Error)
  6335. {
  6336. t_Status = QuadState::State_Error;
  6337. }
  6338. else
  6339. {
  6340. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6341. if ( t_Left )
  6342. {
  6343. t_Status = RecursiveDisjunctiveNormalForm ( t_Left ) ;
  6344. if ( t_Status == QuadState :: State_ReEvaluate )
  6345. {
  6346. t_Status = RecursiveDisjunctiveNormalForm ( a_Node ) ;
  6347. return t_Status ;
  6348. }
  6349. }
  6350. }
  6351. }
  6352. }
  6353. return t_Status ;
  6354. }
  6355. /******************************************************************************
  6356. *
  6357. * Name:
  6358. *
  6359. *
  6360. * Description:
  6361. *
  6362. *
  6363. *****************************************************************************/
  6364. QueryPreprocessor :: QuadState QueryPreprocessor :: DisjunctiveNormalForm ( WmiTreeNode *&a_Root )
  6365. {
  6366. QueryPreprocessor :: QuadState t_Status = RecursiveDisjunctiveNormalForm ( a_Root ) ;
  6367. if ( t_Status == QuadState :: State_ReEvaluate )
  6368. {
  6369. t_Status = DisjunctiveNormalForm ( a_Root ) ;
  6370. }
  6371. return t_Status ;
  6372. }
  6373. /******************************************************************************
  6374. *
  6375. * Name:
  6376. *
  6377. *
  6378. * Description:
  6379. *
  6380. *
  6381. *****************************************************************************/
  6382. QueryPreprocessor :: QuadState QueryPreprocessor :: RecursiveRemoveInvariants (
  6383. void *a_Context ,
  6384. WmiTreeNode *&a_Node
  6385. )
  6386. {
  6387. QueryPreprocessor :: QuadState t_Status = State_Undefined ;
  6388. if ( a_Node )
  6389. {
  6390. if ( a_Node->GetType () == TypeId_WmiOrNode )
  6391. {
  6392. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6393. WmiTreeNode *t_Right = a_Node->GetRight () ;
  6394. if ( t_Left )
  6395. {
  6396. t_Status = RecursiveRemoveInvariants ( a_Context , t_Left ) ;
  6397. if ( t_Status == State_False )
  6398. {
  6399. TransformOrFalseEvaluation (
  6400. a_Node ,
  6401. t_Right
  6402. ) ;
  6403. t_Status = QueryPreprocessor :: QuadState :: State_ReEvaluate ;
  6404. return t_Status ;
  6405. }
  6406. else if ( t_Status == State_True )
  6407. {
  6408. return t_Status ;
  6409. }
  6410. else if ( t_Status == State_ReEvaluate )
  6411. {
  6412. t_Status = RecursiveRemoveInvariants ( a_Context, a_Node ) ;
  6413. return t_Status ;
  6414. }
  6415. }
  6416. if ( t_Right )
  6417. {
  6418. t_Status = RecursiveRemoveInvariants ( a_Context , t_Right ) ;
  6419. if ( t_Status == State_False )
  6420. {
  6421. TransformOrFalseEvaluation (
  6422. a_Node ,
  6423. t_Left
  6424. ) ;
  6425. t_Status = QueryPreprocessor :: QuadState :: State_ReEvaluate ;
  6426. return t_Status ;
  6427. }
  6428. else if ( t_Status == State_True )
  6429. {
  6430. return t_Status ;
  6431. }
  6432. else if ( t_Status == State_ReEvaluate )
  6433. {
  6434. t_Status = RecursiveRemoveInvariants ( a_Context , a_Node ) ;
  6435. return t_Status ;
  6436. }
  6437. }
  6438. }
  6439. else if ( a_Node->GetType () == TypeId_WmiAndNode )
  6440. {
  6441. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6442. WmiTreeNode *t_Right = a_Node->GetRight () ;
  6443. if ( t_Left )
  6444. {
  6445. t_Status = RecursiveRemoveInvariants ( a_Context , t_Left ) ;
  6446. if ( t_Status == State_False )
  6447. {
  6448. return t_Status ;
  6449. }
  6450. else if ( t_Status == State_True )
  6451. {
  6452. TransformAndTrueEvaluation (
  6453. a_Node ,
  6454. t_Right
  6455. ) ;
  6456. t_Status = QueryPreprocessor :: QuadState :: State_ReEvaluate ;
  6457. return t_Status ;
  6458. }
  6459. else if ( t_Status == State_ReEvaluate )
  6460. {
  6461. t_Status = RecursiveRemoveInvariants ( a_Context , a_Node ) ;
  6462. return t_Status ;
  6463. }
  6464. }
  6465. if ( t_Right )
  6466. {
  6467. t_Status = RecursiveRemoveInvariants ( a_Context , t_Right ) ;
  6468. if ( t_Status == State_False )
  6469. {
  6470. return t_Status ;
  6471. }
  6472. else if ( t_Status == State_True )
  6473. {
  6474. TransformAndTrueEvaluation (
  6475. a_Node ,
  6476. t_Left
  6477. ) ;
  6478. t_Status = QueryPreprocessor :: QuadState :: State_ReEvaluate ;
  6479. return t_Status ;
  6480. }
  6481. else if ( t_Status == State_ReEvaluate )
  6482. {
  6483. t_Status = RecursiveRemoveInvariants ( a_Context , a_Node ) ;
  6484. return t_Status ;
  6485. }
  6486. }
  6487. }
  6488. else if ( a_Node->GetType () == TypeId_WmiNotNode )
  6489. {
  6490. // Should never happen, failure in DFN evaluation otherwise
  6491. _DBG_ASSERT(FALSE);
  6492. }
  6493. else if ( a_Node->GetType () == TypeId_WmiOperatorEqualNode )
  6494. {
  6495. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6496. if ( t_Left )
  6497. {
  6498. t_Status = InvariantEvaluate (
  6499. a_Context ,
  6500. a_Node ,
  6501. t_Left
  6502. ) ;
  6503. }
  6504. else
  6505. {
  6506. // Should never happen, failure in DFN evaluation otherwise
  6507. _DBG_ASSERT(FALSE);
  6508. }
  6509. }
  6510. else if ( a_Node->GetType () == TypeId_WmiOperatorNotEqualNode )
  6511. {
  6512. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6513. if ( t_Left )
  6514. {
  6515. t_Status = InvariantEvaluate (
  6516. a_Context ,
  6517. a_Node ,
  6518. t_Left
  6519. ) ;
  6520. }
  6521. else
  6522. {
  6523. // Should never happen, failure in DFN evaluation otherwise
  6524. _DBG_ASSERT(FALSE);
  6525. }
  6526. }
  6527. else if ( a_Node->GetType () == TypeId_WmiOperatorEqualOrGreaterNode )
  6528. {
  6529. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6530. if ( t_Left )
  6531. {
  6532. t_Status = InvariantEvaluate (
  6533. a_Context ,
  6534. a_Node ,
  6535. t_Left
  6536. ) ;
  6537. }
  6538. else
  6539. {
  6540. // Should never happen, failure in DFN evaluation otherwise
  6541. _DBG_ASSERT(FALSE);
  6542. }
  6543. }
  6544. else if ( a_Node->GetType () == TypeId_WmiOperatorEqualOrLessNode )
  6545. {
  6546. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6547. if ( t_Left )
  6548. {
  6549. t_Status = InvariantEvaluate (
  6550. a_Context ,
  6551. a_Node ,
  6552. t_Left
  6553. ) ;
  6554. }
  6555. else
  6556. {
  6557. // Should never happen, failure in DFN evaluation otherwise
  6558. _DBG_ASSERT(FALSE);
  6559. }
  6560. }
  6561. else if ( a_Node->GetType () == TypeId_WmiOperatorLessNode )
  6562. {
  6563. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6564. if ( t_Left )
  6565. {
  6566. t_Status = InvariantEvaluate (
  6567. a_Context ,
  6568. a_Node ,
  6569. t_Left
  6570. ) ;
  6571. }
  6572. else
  6573. {
  6574. // Should never happen, failure in DFN evaluation otherwise
  6575. _DBG_ASSERT(FALSE);
  6576. }
  6577. }
  6578. else if ( a_Node->GetType () == TypeId_WmiOperatorGreaterNode )
  6579. {
  6580. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6581. if ( t_Left )
  6582. {
  6583. t_Status = InvariantEvaluate (
  6584. a_Context ,
  6585. a_Node ,
  6586. t_Left
  6587. ) ;
  6588. }
  6589. else
  6590. {
  6591. // Should never happen, failure in DFN evaluation otherwise
  6592. _DBG_ASSERT(FALSE);
  6593. }
  6594. }
  6595. else if ( a_Node->GetType () == TypeId_WmiOperatorLikeNode )
  6596. {
  6597. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6598. if ( t_Left )
  6599. {
  6600. t_Status = InvariantEvaluate (
  6601. a_Context ,
  6602. a_Node ,
  6603. t_Left
  6604. ) ;
  6605. }
  6606. else
  6607. {
  6608. // Should never happen, failure in DFN evaluation otherwise
  6609. _DBG_ASSERT(FALSE);
  6610. }
  6611. }
  6612. else if ( a_Node->GetType () == TypeId_WmiOperatorNotLikeNode )
  6613. {
  6614. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6615. if ( t_Left )
  6616. {
  6617. t_Status = InvariantEvaluate (
  6618. a_Context ,
  6619. a_Node ,
  6620. t_Left
  6621. ) ;
  6622. }
  6623. else
  6624. {
  6625. // Should never happen, failure in DFN evaluation otherwise
  6626. _DBG_ASSERT(FALSE);
  6627. }
  6628. }
  6629. else if ( a_Node->GetType () == TypeId_WmiOperatorIsANode )
  6630. {
  6631. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6632. if ( t_Left )
  6633. {
  6634. t_Status = InvariantEvaluate (
  6635. a_Context ,
  6636. a_Node ,
  6637. t_Left
  6638. ) ;
  6639. }
  6640. else
  6641. {
  6642. // Should never happen, failure in DFN evaluation otherwise
  6643. _DBG_ASSERT(FALSE);
  6644. }
  6645. }
  6646. else if ( a_Node->GetType () == TypeId_WmiOperatorNotIsANode )
  6647. {
  6648. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6649. if ( t_Left )
  6650. {
  6651. t_Status = InvariantEvaluate (
  6652. a_Context ,
  6653. a_Node ,
  6654. t_Left
  6655. ) ;
  6656. }
  6657. else
  6658. {
  6659. // Should never happen, failure in DFN evaluation otherwise
  6660. _DBG_ASSERT(FALSE);
  6661. }
  6662. }
  6663. else
  6664. {
  6665. // Should never happen, failure in DFN evaluation otherwise
  6666. _DBG_ASSERT(FALSE);
  6667. }
  6668. }
  6669. return t_Status ;
  6670. }
  6671. /******************************************************************************
  6672. *
  6673. * Name:
  6674. *
  6675. *
  6676. * Description:
  6677. *
  6678. *
  6679. *****************************************************************************/
  6680. QueryPreprocessor :: QuadState QueryPreprocessor :: RemoveInvariants (
  6681. void *a_Context ,
  6682. WmiTreeNode *&a_Root
  6683. )
  6684. {
  6685. QuadState t_Status = RecursiveRemoveInvariants ( a_Context , a_Root ) ;
  6686. if ( t_Status == State_ReEvaluate )
  6687. {
  6688. t_Status = RemoveInvariants ( a_Context , a_Root ) ;
  6689. if ( t_Status == State_False || t_Status == State_True )
  6690. {
  6691. delete a_Root ;
  6692. a_Root = NULL ;
  6693. }
  6694. }
  6695. return t_Status ;
  6696. }
  6697. /******************************************************************************
  6698. *
  6699. * Name:
  6700. *
  6701. *
  6702. * Description:
  6703. *
  6704. *
  6705. *****************************************************************************/
  6706. WmiTriState QueryPreprocessor :: RecursiveInsertNode ( WmiTreeNode *&a_Node , WmiTreeNode *&a_Insertion )
  6707. {
  6708. WmiTriState t_Status = :: State_False ;
  6709. if ( a_Node )
  6710. {
  6711. if ( a_Node->GetType () == TypeId_WmiAndNode )
  6712. {
  6713. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6714. if ( t_Left )
  6715. {
  6716. t_Status = RecursiveInsertNode ( t_Left , a_Insertion ) ;
  6717. if ( t_Status != :: State_False )
  6718. {
  6719. return t_Status ;
  6720. }
  6721. }
  6722. WmiTreeNode *t_Right = a_Node->GetRight () ;
  6723. if ( t_Right )
  6724. {
  6725. t_Status = RecursiveInsertNode ( t_Right , a_Insertion ) ;
  6726. if ( t_Status != :: State_False )
  6727. {
  6728. return t_Status ;
  6729. }
  6730. }
  6731. }
  6732. else if ( a_Node->GetType () == TypeId_WmiOrNode )
  6733. {
  6734. // Should never happen, failure in DFN evaluation otherwise
  6735. _DBG_ASSERT(FALSE);
  6736. }
  6737. else if ( a_Node->GetType () == TypeId_WmiNotNode )
  6738. {
  6739. // Should never happen, failure in DFN evaluation otherwise
  6740. _DBG_ASSERT(FALSE);
  6741. }
  6742. else
  6743. {
  6744. // Operator
  6745. WmiValueNode *t_CompareValue = ( WmiValueNode * ) a_Node->GetLeft () ;
  6746. WmiValueNode *t_InsertionValue = ( WmiValueNode * ) a_Insertion->GetLeft () ;
  6747. LONG t_Compare = t_InsertionValue ->ComparePropertyName ( *t_CompareValue ) ;
  6748. if ( t_Compare < 0 )
  6749. {
  6750. // Insert to left
  6751. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  6752. WmiTreeNode *t_NewAndNode = new WmiAndNode ( a_Insertion , a_Node , t_Parent ) ;
  6753. if ( t_NewAndNode )
  6754. {
  6755. a_Node->SetParent ( t_NewAndNode ) ;
  6756. a_Insertion->SetParent ( t_NewAndNode ) ;
  6757. if ( t_Parent )
  6758. {
  6759. if ( t_Parent->GetLeft () == a_Node )
  6760. {
  6761. t_Parent->SetLeft ( t_NewAndNode ) ;
  6762. }
  6763. else
  6764. {
  6765. t_Parent->SetRight ( t_NewAndNode ) ;
  6766. }
  6767. }
  6768. a_Node = t_NewAndNode ;
  6769. t_Status = :: State_True ;
  6770. }
  6771. else
  6772. {
  6773. t_Status = :: State_Error ;
  6774. }
  6775. }
  6776. else
  6777. {
  6778. t_Status = :: State_False ;
  6779. }
  6780. }
  6781. }
  6782. else
  6783. {
  6784. a_Node = a_Insertion ;
  6785. t_Status = :: State_True ;
  6786. }
  6787. return t_Status ;
  6788. }
  6789. /******************************************************************************
  6790. *
  6791. * Name:
  6792. *
  6793. *
  6794. * Description:
  6795. *
  6796. *
  6797. *****************************************************************************/
  6798. WmiTriState QueryPreprocessor :: InsertNode ( WmiTreeNode *&a_NewRoot , WmiTreeNode *&a_Insertion )
  6799. {
  6800. WmiTriState t_Status = RecursiveInsertNode ( a_NewRoot , a_Insertion ) ;
  6801. if ( t_Status == :: State_False )
  6802. {
  6803. // Insert to right
  6804. WmiTreeNode *t_Parent = a_NewRoot->GetParent () ;
  6805. WmiTreeNode *t_NewAndNode = new WmiAndNode ( a_NewRoot , a_Insertion , t_Parent ) ;
  6806. if ( t_NewAndNode )
  6807. {
  6808. a_NewRoot->SetParent ( t_NewAndNode ) ;
  6809. a_Insertion->SetParent ( t_NewAndNode ) ;
  6810. if ( t_Parent )
  6811. {
  6812. if ( t_Parent->GetLeft () == a_NewRoot )
  6813. {
  6814. t_Parent->SetLeft ( t_NewAndNode ) ;
  6815. }
  6816. else
  6817. {
  6818. t_Parent->SetRight ( t_NewAndNode ) ;
  6819. }
  6820. }
  6821. a_NewRoot = t_NewAndNode ;
  6822. }
  6823. else
  6824. {
  6825. return :: State_Error ;
  6826. }
  6827. }
  6828. return :: State_True ;
  6829. }
  6830. /******************************************************************************
  6831. *
  6832. * Name:
  6833. *
  6834. *
  6835. * Description:
  6836. *
  6837. *
  6838. *****************************************************************************/
  6839. WmiTriState QueryPreprocessor :: RecursiveSortConditionals ( WmiTreeNode *&a_NewRoot , WmiTreeNode *&a_Node )
  6840. {
  6841. WmiTriState t_Status = :: State_False ;
  6842. if ( a_Node )
  6843. {
  6844. if ( a_Node->GetType () == TypeId_WmiAndNode )
  6845. {
  6846. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6847. WmiTreeNode *t_Right = a_Node->GetRight () ;
  6848. if ( t_Left )
  6849. {
  6850. t_Status = RecursiveSortConditionals ( a_NewRoot , t_Left ) ;
  6851. a_Node->SetLeft ( NULL ) ;
  6852. delete t_Left ;
  6853. }
  6854. if ( t_Right )
  6855. {
  6856. t_Status = RecursiveSortConditionals ( a_NewRoot , t_Right ) ;
  6857. a_Node->SetRight ( NULL ) ;
  6858. delete t_Right ;
  6859. }
  6860. }
  6861. else if ( a_Node->GetType () == TypeId_WmiOrNode )
  6862. {
  6863. // Should never happen, failure in DFN evaluation otherwise
  6864. _DBG_ASSERT(FALSE);
  6865. }
  6866. else if ( a_Node->GetType () == TypeId_WmiNotNode )
  6867. {
  6868. // Should never happen, failure in DFN evaluation otherwise
  6869. _DBG_ASSERT(FALSE);
  6870. }
  6871. else
  6872. {
  6873. // Operator
  6874. WmiTreeNode *t_Parent = a_Node->GetParent () ;
  6875. if ( t_Parent )
  6876. {
  6877. if ( t_Parent->GetLeft () == a_Node )
  6878. {
  6879. t_Parent->SetLeft ( NULL ) ;
  6880. }
  6881. else
  6882. {
  6883. t_Parent->SetRight ( NULL ) ;
  6884. }
  6885. }
  6886. a_Node->SetParent ( NULL ) ;
  6887. t_Status = InsertNode ( a_NewRoot , a_Node ) ;
  6888. a_Node = NULL ;
  6889. }
  6890. }
  6891. return t_Status ;
  6892. }
  6893. /******************************************************************************
  6894. *
  6895. * Name:
  6896. *
  6897. *
  6898. * Description:
  6899. *
  6900. *
  6901. *****************************************************************************/
  6902. WmiTriState QueryPreprocessor :: SortConditionals ( WmiTreeNode *&a_Root )
  6903. {
  6904. WmiTreeNode *t_NewRoot = NULL ;
  6905. WmiTriState t_Status = RecursiveSortConditionals ( t_NewRoot , a_Root ) ;
  6906. if ( a_Root )
  6907. {
  6908. WmiTreeNode *t_Parent = a_Root->GetParent () ;
  6909. if ( t_Parent )
  6910. {
  6911. if ( t_Parent->GetLeft () == a_Root )
  6912. {
  6913. t_Parent->SetLeft ( t_NewRoot ) ;
  6914. }
  6915. else
  6916. {
  6917. t_Parent->SetRight ( t_NewRoot ) ;
  6918. }
  6919. }
  6920. t_NewRoot->SetParent ( t_Parent ) ;
  6921. delete a_Root ;
  6922. }
  6923. a_Root = t_NewRoot ;
  6924. return t_Status ;
  6925. }
  6926. /******************************************************************************
  6927. *
  6928. * Name:
  6929. *
  6930. *
  6931. * Description:
  6932. *
  6933. *
  6934. *****************************************************************************/
  6935. WmiTriState QueryPreprocessor :: RecursiveSort ( WmiTreeNode *&a_Node )
  6936. {
  6937. WmiTriState t_Status = :: State_False ;
  6938. if ( a_Node )
  6939. {
  6940. if ( a_Node->GetType () == TypeId_WmiOrNode )
  6941. {
  6942. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  6943. WmiTreeNode *t_Right = a_Node->GetRight () ;
  6944. if ( t_Left )
  6945. {
  6946. t_Status = RecursiveSort ( t_Left ) ;
  6947. }
  6948. if ( t_Status == :: State_True )
  6949. {
  6950. if ( t_Right )
  6951. {
  6952. t_Status = RecursiveSort ( t_Right ) ;
  6953. }
  6954. }
  6955. }
  6956. else if ( a_Node->GetType () == TypeId_WmiAndNode )
  6957. {
  6958. t_Status = SortConditionals ( a_Node ) ;
  6959. }
  6960. else if ( a_Node->GetType () == TypeId_WmiNotNode )
  6961. {
  6962. // Should never happen, failure in DFN evaluation otherwise
  6963. _DBG_ASSERT(FALSE);
  6964. }
  6965. else
  6966. {
  6967. // Single operand
  6968. t_Status = :: State_True ;
  6969. }
  6970. }
  6971. return t_Status ;
  6972. }
  6973. /******************************************************************************
  6974. *
  6975. * Name:
  6976. *
  6977. *
  6978. * Description:
  6979. *
  6980. *
  6981. *****************************************************************************/
  6982. WmiTriState QueryPreprocessor :: Sort ( WmiTreeNode *&a_Root )
  6983. {
  6984. WmiTriState t_Status = RecursiveSort ( a_Root ) ;
  6985. return t_Status ;
  6986. }
  6987. /******************************************************************************
  6988. *
  6989. * Name:
  6990. *
  6991. *
  6992. * Description:
  6993. *
  6994. *
  6995. *****************************************************************************/
  6996. WmiTriState QueryPreprocessor :: RecursiveConvertToRanges ( WmiTreeNode *&a_Node )
  6997. {
  6998. WmiTriState t_Status = :: State_True ;
  6999. if ( a_Node )
  7000. {
  7001. if ( a_Node->GetType () == TypeId_WmiOrNode )
  7002. {
  7003. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  7004. WmiTreeNode *t_Right = a_Node->GetRight () ;
  7005. if ( t_Left )
  7006. {
  7007. t_Status = RecursiveConvertToRanges ( t_Left ) ;
  7008. }
  7009. if ( t_Right )
  7010. {
  7011. t_Status = RecursiveConvertToRanges ( t_Right ) ;
  7012. }
  7013. }
  7014. else if ( a_Node->GetType () == TypeId_WmiAndNode )
  7015. {
  7016. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  7017. WmiTreeNode *t_Right = a_Node->GetRight () ;
  7018. if ( t_Left )
  7019. {
  7020. t_Status = RecursiveConvertToRanges ( t_Left ) ;
  7021. }
  7022. if ( t_Right )
  7023. {
  7024. t_Status = RecursiveConvertToRanges ( t_Right ) ;
  7025. }
  7026. }
  7027. else if ( a_Node->GetType () == TypeId_WmiNotNode )
  7028. {
  7029. // Should never happen, failure in DFN evaluation otherwise
  7030. _DBG_ASSERT(FALSE);
  7031. }
  7032. else if ( a_Node->GetType () == TypeId_WmiOperatorEqualNode )
  7033. {
  7034. TransformOperatorToRange ( a_Node ) ;
  7035. return a_Node ? :: State_True : :: State_Error ;
  7036. }
  7037. else if ( a_Node->GetType () == TypeId_WmiOperatorEqualOrGreaterNode )
  7038. {
  7039. TransformOperatorToRange ( a_Node ) ;
  7040. return a_Node ? :: State_True : :: State_Error ;
  7041. }
  7042. else if ( a_Node->GetType () == TypeId_WmiOperatorEqualOrLessNode )
  7043. {
  7044. TransformOperatorToRange ( a_Node ) ;
  7045. return a_Node ? :: State_True : :: State_Error ;
  7046. }
  7047. else if ( a_Node->GetType () == TypeId_WmiOperatorLessNode )
  7048. {
  7049. TransformOperatorToRange ( a_Node ) ;
  7050. return a_Node ? :: State_True : :: State_Error ;
  7051. }
  7052. else if ( a_Node->GetType () == TypeId_WmiOperatorGreaterNode )
  7053. {
  7054. TransformOperatorToRange ( a_Node ) ;
  7055. return a_Node ? :: State_True : :: State_Error ;
  7056. }
  7057. else if ( a_Node->GetType () == TypeId_WmiOperatorLikeNode )
  7058. {
  7059. TransformOperatorToRange ( a_Node ) ;
  7060. return a_Node ? :: State_True : :: State_Error ;
  7061. }
  7062. else if ( a_Node->GetType () == TypeId_WmiOperatorNotLikeNode )
  7063. {
  7064. TransformOperatorToRange ( a_Node ) ;
  7065. return a_Node ? :: State_True : :: State_Error ;
  7066. }
  7067. else if ( a_Node->GetType () == TypeId_WmiOperatorIsANode )
  7068. {
  7069. TransformOperatorToRange ( a_Node ) ;
  7070. return a_Node ? :: State_True : :: State_Error ;
  7071. }
  7072. else if ( a_Node->GetType () == TypeId_WmiOperatorNotIsANode )
  7073. {
  7074. TransformOperatorToRange ( a_Node ) ;
  7075. return a_Node ? :: State_True : :: State_Error ;
  7076. }
  7077. else
  7078. {
  7079. // Should never happen, failure in DFN evaluation otherwise
  7080. _DBG_ASSERT(FALSE);
  7081. }
  7082. }
  7083. return t_Status ;
  7084. }
  7085. /******************************************************************************
  7086. *
  7087. * Name:
  7088. *
  7089. *
  7090. * Description:
  7091. *
  7092. *
  7093. *****************************************************************************/
  7094. WmiTriState QueryPreprocessor :: ConvertToRanges ( WmiTreeNode *&a_Root )
  7095. {
  7096. return RecursiveConvertToRanges ( a_Root ) ;
  7097. }
  7098. /******************************************************************************
  7099. *
  7100. * Name:
  7101. *
  7102. *
  7103. * Description:
  7104. *
  7105. *
  7106. *****************************************************************************/
  7107. void QueryPreprocessor :: TransformIntersectingRange (
  7108. WmiTreeNode *&a_Node ,
  7109. WmiTreeNode *a_Compare ,
  7110. WmiTreeNode *a_Intersection
  7111. )
  7112. {
  7113. WmiTreeNode *t_CompareParent = a_Compare->GetParent () ;
  7114. if ( t_CompareParent )
  7115. {
  7116. if ( t_CompareParent->GetLeft () == a_Compare )
  7117. {
  7118. t_CompareParent->SetLeft ( a_Intersection ) ;
  7119. }
  7120. else
  7121. {
  7122. t_CompareParent->SetRight ( a_Intersection ) ;
  7123. }
  7124. a_Intersection->SetParent ( t_CompareParent ) ;
  7125. delete a_Compare ;
  7126. a_Compare = NULL ;
  7127. }
  7128. else
  7129. {
  7130. // Should never happen
  7131. _DBG_ASSERT(FALSE);
  7132. }
  7133. }
  7134. /******************************************************************************
  7135. *
  7136. * Name:
  7137. *
  7138. *
  7139. * Description:
  7140. *
  7141. *
  7142. *****************************************************************************/
  7143. void QueryPreprocessor :: TransformNonIntersectingRange (
  7144. WmiTreeNode *&a_Node ,
  7145. WmiTreeNode *a_Compare
  7146. )
  7147. {
  7148. }
  7149. /******************************************************************************
  7150. *
  7151. * Name:
  7152. *
  7153. *
  7154. * Description:
  7155. *
  7156. *
  7157. *****************************************************************************/
  7158. QueryPreprocessor :: QuadState QueryPreprocessor :: RecursiveRemoveNonOverlappingRanges ( WmiTreeNode *&a_Node , WmiTreeNode *&a_Compare )
  7159. {
  7160. QueryPreprocessor :: QuadState t_Status = QueryPreprocessor :: QuadState :: State_Undefined ;
  7161. if ( a_Node )
  7162. {
  7163. if ( a_Node->GetType () == TypeId_WmiOrNode )
  7164. {
  7165. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  7166. if ( t_Left )
  7167. {
  7168. a_Compare = NULL ;
  7169. t_Status = RecursiveRemoveNonOverlappingRanges ( t_Left , a_Compare ) ;
  7170. if ( t_Status == State_False )
  7171. {
  7172. WmiTreeNode *t_Right = a_Node->GetRight () ;
  7173. TransformOrFalseEvaluation (
  7174. a_Node ,
  7175. t_Right
  7176. ) ;
  7177. return QueryPreprocessor :: QuadState :: State_ReEvaluate ;
  7178. }
  7179. else if ( t_Status == State_True )
  7180. {
  7181. return t_Status ;
  7182. }
  7183. else if ( t_Status == State_ReEvaluate )
  7184. {
  7185. t_Status = RecursiveRemoveNonOverlappingRanges ( a_Node , a_Compare ) ;
  7186. return t_Status ;
  7187. }
  7188. }
  7189. WmiTreeNode *t_Right = a_Node->GetRight () ;
  7190. if ( t_Right )
  7191. {
  7192. a_Compare = NULL ;
  7193. t_Status = RecursiveRemoveNonOverlappingRanges ( t_Right , a_Compare ) ;
  7194. if ( t_Status == State_False )
  7195. {
  7196. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  7197. TransformOrFalseEvaluation (
  7198. a_Node ,
  7199. t_Left
  7200. ) ;
  7201. return QueryPreprocessor :: QuadState :: State_ReEvaluate ;
  7202. }
  7203. else if ( t_Status == State_True )
  7204. {
  7205. return t_Status ;
  7206. }
  7207. else if ( t_Status == State_ReEvaluate )
  7208. {
  7209. t_Status = RecursiveRemoveNonOverlappingRanges ( a_Node , a_Compare ) ;
  7210. return t_Status ;
  7211. }
  7212. }
  7213. }
  7214. else if ( a_Node->GetType () == TypeId_WmiAndNode )
  7215. {
  7216. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  7217. if ( t_Left )
  7218. {
  7219. t_Status = RecursiveRemoveNonOverlappingRanges ( t_Left , a_Compare ) ;
  7220. if ( t_Status == State_True )
  7221. {
  7222. WmiTreeNode *t_Right = a_Node->GetRight () ;
  7223. TransformAndTrueEvaluation (
  7224. a_Node ,
  7225. t_Right
  7226. ) ;
  7227. a_Compare = NULL ;
  7228. return QueryPreprocessor :: QuadState :: State_ReEvaluate ;
  7229. }
  7230. else if ( t_Status == State_False )
  7231. {
  7232. return t_Status ;
  7233. }
  7234. else if ( t_Status == State_ReEvaluate )
  7235. {
  7236. t_Status = RecursiveRemoveNonOverlappingRanges ( a_Node , a_Compare ) ;
  7237. return t_Status ;
  7238. }
  7239. }
  7240. WmiTreeNode *t_Right = a_Node->GetRight () ;
  7241. if ( t_Right )
  7242. {
  7243. t_Status = RecursiveRemoveNonOverlappingRanges ( t_Right , a_Compare ) ;
  7244. if ( t_Status == State_True )
  7245. {
  7246. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  7247. TransformAndTrueEvaluation (
  7248. a_Node ,
  7249. t_Left
  7250. ) ;
  7251. a_Compare = NULL;
  7252. return QueryPreprocessor :: QuadState :: State_ReEvaluate ;
  7253. }
  7254. else if ( t_Status == State_False )
  7255. {
  7256. return t_Status ;
  7257. }
  7258. else if ( t_Status == State_ReEvaluate )
  7259. {
  7260. t_Status = RecursiveRemoveNonOverlappingRanges ( a_Node , a_Compare ) ;
  7261. return t_Status ;
  7262. }
  7263. }
  7264. }
  7265. else if ( a_Node->GetType () == TypeId_WmiNullRangeNode )
  7266. {
  7267. WmiRangeNode *t_Node = ( WmiRangeNode * ) a_Node ;
  7268. if ( a_Compare )
  7269. {
  7270. WmiRangeNode *t_Range = ( WmiRangeNode * ) a_Compare ;
  7271. LONG t_Result = t_Node->ComparePropertyName ( *t_Range ) ;
  7272. if ( t_Result == 0 )
  7273. {
  7274. if ( t_Range->GetType () == TypeId_WmiNullRangeNode )
  7275. {
  7276. WmiTreeNode *t_Intersection = a_Node->Copy () ;
  7277. TransformIntersectingRange (
  7278. a_Node ,
  7279. a_Compare ,
  7280. t_Intersection
  7281. ) ;
  7282. a_Compare = t_Intersection ;
  7283. t_Status = QueryPreprocessor :: QuadState :: State_True ;
  7284. }
  7285. else
  7286. {
  7287. // Failure, incompatible types
  7288. }
  7289. }
  7290. else
  7291. {
  7292. a_Compare = a_Node ;
  7293. }
  7294. }
  7295. else
  7296. {
  7297. a_Compare = a_Node ;
  7298. }
  7299. }
  7300. else if ( a_Node->GetType () == TypeId_WmiStringRangeNode )
  7301. {
  7302. WmiStringRangeNode *t_Node = ( WmiStringRangeNode * ) a_Node ;
  7303. if ( a_Compare )
  7304. {
  7305. WmiRangeNode *t_Range = ( WmiRangeNode * ) a_Compare ;
  7306. LONG t_Result = t_Node->ComparePropertyName ( *t_Range ) ;
  7307. if ( t_Result == 0 )
  7308. {
  7309. if ( t_Range->GetType () == TypeId_WmiStringRangeNode )
  7310. {
  7311. WmiStringRangeNode *t_StringRange = ( WmiStringRangeNode * ) t_Range ;
  7312. WmiStringRangeNode *t_Intersection = NULL ;
  7313. WmiTriState t_Intersected = t_StringRange->GetIntersectingRange (
  7314. *t_Node ,
  7315. t_Intersection
  7316. ) ;
  7317. switch ( t_Intersected )
  7318. {
  7319. case :: State_True:
  7320. {
  7321. TransformIntersectingRange (
  7322. a_Node ,
  7323. a_Compare ,
  7324. t_Intersection
  7325. ) ;
  7326. a_Compare = t_Intersection ;
  7327. t_Status = QueryPreprocessor :: QuadState :: State_True ;
  7328. }
  7329. break ;
  7330. case :: State_False:
  7331. {
  7332. TransformNonIntersectingRange (
  7333. a_Node ,
  7334. a_Compare
  7335. ) ;
  7336. a_Compare = NULL ;
  7337. t_Status = QueryPreprocessor :: QuadState :: State_False ;
  7338. }
  7339. break ;
  7340. default:
  7341. {
  7342. t_Status = QueryPreprocessor :: QuadState :: State_Error ;
  7343. }
  7344. break ;
  7345. }
  7346. }
  7347. else
  7348. {
  7349. // Failure, incompatible types
  7350. }
  7351. }
  7352. else
  7353. {
  7354. a_Compare = a_Node ;
  7355. }
  7356. }
  7357. else
  7358. {
  7359. a_Compare = a_Node ;
  7360. }
  7361. }
  7362. else if ( a_Node->GetType () == TypeId_WmiUnsignedIntegerRangeNode )
  7363. {
  7364. WmiUnsignedIntegerRangeNode *t_Node = ( WmiUnsignedIntegerRangeNode * ) a_Node ;
  7365. if ( a_Compare )
  7366. {
  7367. WmiRangeNode *t_Range = ( WmiRangeNode * ) a_Compare ;
  7368. LONG t_Result = t_Node->ComparePropertyName ( *t_Range ) ;
  7369. if ( t_Result == 0 )
  7370. {
  7371. if ( t_Range->GetType () == TypeId_WmiUnsignedIntegerRangeNode )
  7372. {
  7373. WmiUnsignedIntegerRangeNode *t_IntegerRange = ( WmiUnsignedIntegerRangeNode * ) t_Range ;
  7374. WmiUnsignedIntegerRangeNode *t_Intersection = NULL ;
  7375. WmiTriState t_Intersected = t_IntegerRange->GetIntersectingRange (
  7376. *t_Node ,
  7377. t_Intersection
  7378. ) ;
  7379. switch ( t_Intersected )
  7380. {
  7381. case :: State_True:
  7382. {
  7383. TransformIntersectingRange (
  7384. a_Node ,
  7385. a_Compare ,
  7386. t_Intersection
  7387. ) ;
  7388. a_Compare = t_Intersection ;
  7389. t_Status = QueryPreprocessor :: QuadState :: State_True ;
  7390. }
  7391. break ;
  7392. case :: State_False:
  7393. {
  7394. TransformNonIntersectingRange (
  7395. a_Node ,
  7396. a_Compare
  7397. ) ;
  7398. a_Compare = NULL ;
  7399. t_Status = QueryPreprocessor :: QuadState :: State_False ;
  7400. }
  7401. break;
  7402. default:
  7403. {
  7404. t_Status = QueryPreprocessor :: QuadState :: State_Error ;
  7405. }
  7406. break ;
  7407. }
  7408. }
  7409. else
  7410. {
  7411. // Failure, incompatible types
  7412. }
  7413. }
  7414. else
  7415. {
  7416. a_Compare = a_Node ;
  7417. }
  7418. }
  7419. else
  7420. {
  7421. a_Compare = a_Node ;
  7422. }
  7423. }
  7424. else if ( a_Node->GetType () == TypeId_WmiSignedIntegerRangeNode )
  7425. {
  7426. WmiSignedIntegerRangeNode *t_Node = ( WmiSignedIntegerRangeNode * ) a_Node ;
  7427. if ( a_Compare )
  7428. {
  7429. WmiRangeNode *t_Range = ( WmiRangeNode * ) a_Compare ;
  7430. LONG t_Result = t_Node->ComparePropertyName ( *t_Range ) ;
  7431. if ( t_Result == 0 )
  7432. {
  7433. if ( t_Range->GetType () == TypeId_WmiSignedIntegerRangeNode )
  7434. {
  7435. WmiSignedIntegerRangeNode *t_IntegerRange = ( WmiSignedIntegerRangeNode * ) t_Range ;
  7436. WmiSignedIntegerRangeNode *t_Intersection = NULL ;
  7437. WmiTriState t_Intersected = t_IntegerRange->GetIntersectingRange (
  7438. *t_Node ,
  7439. t_Intersection
  7440. ) ;
  7441. switch ( t_Intersected )
  7442. {
  7443. case :: State_True:
  7444. {
  7445. TransformIntersectingRange (
  7446. a_Node ,
  7447. a_Compare ,
  7448. t_Intersection
  7449. ) ;
  7450. a_Compare = t_Intersection ;
  7451. t_Status = QueryPreprocessor :: QuadState :: State_True ;
  7452. }
  7453. break ;
  7454. case :: State_False:
  7455. {
  7456. TransformNonIntersectingRange (
  7457. a_Node ,
  7458. a_Compare
  7459. ) ;
  7460. a_Compare = NULL ;
  7461. t_Status = QueryPreprocessor :: QuadState :: State_False ;
  7462. }
  7463. break ;
  7464. default:
  7465. {
  7466. t_Status = QueryPreprocessor :: QuadState :: State_Error ;
  7467. }
  7468. break ;
  7469. }
  7470. }
  7471. else
  7472. {
  7473. // Failure, incompatible types
  7474. }
  7475. }
  7476. else
  7477. {
  7478. a_Compare = a_Node ;
  7479. }
  7480. }
  7481. else
  7482. {
  7483. a_Compare = a_Node ;
  7484. }
  7485. }
  7486. else
  7487. {
  7488. // Should never happen, failure in DNF evaluation otherwise
  7489. _DBG_ASSERT(FALSE);
  7490. }
  7491. }
  7492. return t_Status ;
  7493. }
  7494. /******************************************************************************
  7495. *
  7496. * Name:
  7497. *
  7498. *
  7499. * Description:
  7500. *
  7501. *
  7502. *****************************************************************************/
  7503. QueryPreprocessor :: QuadState QueryPreprocessor :: RemoveNonOverlappingRanges ( WmiTreeNode *&a_Root )
  7504. {
  7505. WmiTreeNode *t_Compare = NULL ;
  7506. QueryPreprocessor :: QuadState t_Status = RecursiveRemoveNonOverlappingRanges ( a_Root , t_Compare ) ;
  7507. if ( t_Status == State_ReEvaluate )
  7508. {
  7509. t_Status = RemoveNonOverlappingRanges ( a_Root ) ;
  7510. if ( t_Status == State_False || t_Status == State_True )
  7511. {
  7512. delete a_Root ;
  7513. a_Root = NULL ;
  7514. }
  7515. }
  7516. return t_Status ;
  7517. }
  7518. /******************************************************************************
  7519. *
  7520. * Name:
  7521. *
  7522. *
  7523. * Description:
  7524. *
  7525. *
  7526. *****************************************************************************/
  7527. void QueryPreprocessor :: CountDisjunctions ( WmiTreeNode *a_Node , ULONG &a_Count )
  7528. {
  7529. if ( a_Node )
  7530. {
  7531. if ( a_Node->GetType () == TypeId_WmiOrNode )
  7532. {
  7533. a_Count ++ ;
  7534. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  7535. if ( t_Left )
  7536. {
  7537. CountDisjunctions ( t_Left , a_Count ) ;
  7538. }
  7539. WmiTreeNode *t_Right = a_Node->GetRight () ;
  7540. if ( t_Right )
  7541. {
  7542. CountDisjunctions ( t_Right , a_Count ) ;
  7543. }
  7544. }
  7545. }
  7546. }
  7547. /******************************************************************************
  7548. *
  7549. * Name:
  7550. *
  7551. *
  7552. * Description:
  7553. *
  7554. *
  7555. *****************************************************************************/
  7556. WmiTriState QueryPreprocessor :: CreateDisjunctions (
  7557. void *a_Context ,
  7558. WmiTreeNode *a_Node ,
  7559. Disjunctions *a_Disjunctions ,
  7560. ULONG a_PropertiesToPartitionCount ,
  7561. BSTR *a_PropertiesToPartition ,
  7562. ULONG &a_DisjunctionIndex
  7563. )
  7564. {
  7565. WmiTriState t_Status = :: State_True ;
  7566. if ( a_Node )
  7567. {
  7568. if ( a_Node->GetType () == TypeId_WmiOrNode )
  7569. {
  7570. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  7571. if ( t_Left )
  7572. {
  7573. t_Status = CreateDisjunctions (
  7574. a_Context ,
  7575. t_Left ,
  7576. a_Disjunctions ,
  7577. a_PropertiesToPartitionCount ,
  7578. a_PropertiesToPartition ,
  7579. a_DisjunctionIndex
  7580. ) ;
  7581. }
  7582. if ( t_Status == :: State_True )
  7583. {
  7584. Conjunctions *t_Disjunction = a_Disjunctions->GetDisjunction ( a_DisjunctionIndex ) ;
  7585. for ( ULONG t_Index = 0 ; t_Index < a_PropertiesToPartitionCount ; t_Index ++ )
  7586. {
  7587. if ( t_Disjunction->GetRange ( t_Index ) == NULL )
  7588. {
  7589. WmiRangeNode *t_RangeNode = AllocInfiniteRangeNode (
  7590. a_Context ,
  7591. a_PropertiesToPartition [ t_Index ]
  7592. ) ;
  7593. if ( t_RangeNode )
  7594. {
  7595. t_Disjunction->SetRange ( t_Index , t_RangeNode ) ;
  7596. }
  7597. else
  7598. {
  7599. t_Status = :: State_Error ;
  7600. break ;
  7601. }
  7602. }
  7603. }
  7604. }
  7605. a_DisjunctionIndex ++ ;
  7606. if ( t_Status == :: State_True )
  7607. {
  7608. WmiTreeNode *t_Right = a_Node->GetRight () ;
  7609. if ( t_Right )
  7610. {
  7611. t_Status = CreateDisjunctions (
  7612. a_Context ,
  7613. t_Right ,
  7614. a_Disjunctions ,
  7615. a_PropertiesToPartitionCount ,
  7616. a_PropertiesToPartition ,
  7617. a_DisjunctionIndex
  7618. ) ;
  7619. }
  7620. if ( t_Status == :: State_True )
  7621. {
  7622. Conjunctions *t_Disjunction = a_Disjunctions->GetDisjunction ( a_DisjunctionIndex ) ;
  7623. for ( ULONG t_Index = 0 ; t_Index < a_PropertiesToPartitionCount ; t_Index ++ )
  7624. {
  7625. if ( t_Disjunction->GetRange ( t_Index ) == NULL )
  7626. {
  7627. WmiRangeNode *t_RangeNode = AllocInfiniteRangeNode (
  7628. a_Context ,
  7629. a_PropertiesToPartition [ t_Index ]
  7630. ) ;
  7631. if ( t_RangeNode )
  7632. {
  7633. t_Disjunction->SetRange ( t_Index , t_RangeNode ) ;
  7634. }
  7635. else
  7636. {
  7637. t_Status = :: State_Error ;
  7638. }
  7639. }
  7640. }
  7641. }
  7642. }
  7643. }
  7644. else if ( a_Node->GetType () == TypeId_WmiAndNode )
  7645. {
  7646. WmiTreeNode *t_Left = a_Node->GetLeft () ;
  7647. if ( t_Left )
  7648. {
  7649. t_Status = CreateDisjunctions (
  7650. a_Context ,
  7651. t_Left ,
  7652. a_Disjunctions ,
  7653. a_PropertiesToPartitionCount ,
  7654. a_PropertiesToPartition ,
  7655. a_DisjunctionIndex
  7656. ) ;
  7657. }
  7658. if ( t_Status == :: State_True )
  7659. {
  7660. WmiTreeNode *t_Right = a_Node->GetRight () ;
  7661. if ( t_Right )
  7662. {
  7663. t_Status = CreateDisjunctions (
  7664. a_Context ,
  7665. t_Right ,
  7666. a_Disjunctions ,
  7667. a_PropertiesToPartitionCount ,
  7668. a_PropertiesToPartition ,
  7669. a_DisjunctionIndex
  7670. ) ;
  7671. }
  7672. }
  7673. }
  7674. else
  7675. {
  7676. Conjunctions *t_Disjunction = a_Disjunctions->GetDisjunction ( a_DisjunctionIndex ) ;
  7677. WmiRangeNode *t_Node = ( WmiRangeNode * ) a_Node ;
  7678. BSTR t_PropertyName = t_Node->GetPropertyName () ;
  7679. for ( ULONG t_Index = 0 ; t_Index < a_PropertiesToPartitionCount ; t_Index ++ )
  7680. {
  7681. if ( wbem_wcsicmp ( t_PropertyName , a_PropertiesToPartition [ t_Index ] ) == 0 )
  7682. {
  7683. WmiRangeNode *t_NodeCopy = ( WmiRangeNode * ) t_Node->Copy () ;
  7684. if ( t_NodeCopy )
  7685. {
  7686. t_Disjunction->SetRange ( t_Index , t_NodeCopy ) ;
  7687. }
  7688. else
  7689. {
  7690. t_Status = :: State_Error ;
  7691. }
  7692. break ;
  7693. }
  7694. }
  7695. }
  7696. }
  7697. return t_Status ;
  7698. }
  7699. /******************************************************************************
  7700. *
  7701. * Name:
  7702. *
  7703. *
  7704. * Description:
  7705. *
  7706. *
  7707. *****************************************************************************/
  7708. WmiTriState QueryPreprocessor :: CreateDisjunctionContainer (
  7709. void *a_Context ,
  7710. WmiTreeNode *a_Root ,
  7711. ULONG a_Count ,
  7712. BSTR *a_Container ,
  7713. Disjunctions *&a_Disjunctions
  7714. )
  7715. {
  7716. WmiTriState t_Status = :: State_True ;
  7717. if ( a_Count && a_Container )
  7718. {
  7719. ULONG t_PropertiesToPartitionCount = a_Count ;
  7720. BSTR *t_PropertiesToPartition = a_Container ;
  7721. ULONG t_Count = 1 ;
  7722. CountDisjunctions ( a_Root , t_Count ) ;
  7723. a_Disjunctions = new Disjunctions ( t_Count , t_PropertiesToPartitionCount ) ;
  7724. if ( a_Disjunctions )
  7725. {
  7726. t_Status = a_Disjunctions->Initialize () ;
  7727. if ( t_Status == :: State_True )
  7728. {
  7729. t_Count = 0 ;
  7730. t_Status = CreateDisjunctions (
  7731. a_Context ,
  7732. a_Root ,
  7733. a_Disjunctions ,
  7734. t_PropertiesToPartitionCount ,
  7735. t_PropertiesToPartition ,
  7736. t_Count
  7737. ) ;
  7738. if ( t_Status == :: State_True )
  7739. {
  7740. Conjunctions *t_Disjunction = a_Disjunctions->GetDisjunction ( 0 ) ;
  7741. for ( ULONG t_Index = 0 ; t_Index < t_PropertiesToPartitionCount ; t_Index ++ )
  7742. {
  7743. if ( t_Disjunction->GetRange ( t_Index ) == NULL )
  7744. {
  7745. WmiRangeNode *t_RangeNode = AllocInfiniteRangeNode (
  7746. a_Context ,
  7747. t_PropertiesToPartition [ t_Index ]
  7748. ) ;
  7749. if ( t_RangeNode )
  7750. {
  7751. t_Disjunction->SetRange ( t_Index , t_RangeNode ) ;
  7752. }
  7753. else
  7754. {
  7755. t_Status = :: State_Error ;
  7756. break ;
  7757. }
  7758. }
  7759. }
  7760. }
  7761. }
  7762. }
  7763. else
  7764. {
  7765. t_Status = :: State_Error ;
  7766. }
  7767. }
  7768. return t_Status ;
  7769. }
  7770. /******************************************************************************
  7771. *
  7772. * Name:
  7773. *
  7774. *
  7775. * Description:
  7776. *
  7777. *
  7778. *****************************************************************************/
  7779. void PrintInit (
  7780. Disjunctions *a_Disjunctions ,
  7781. ULONG a_DisjunctionSetToTestCount ,
  7782. ULONG *a_DisjunctionSetToTest ,
  7783. ULONG a_KeyIndex
  7784. )
  7785. {
  7786. for ( ULONG t_Index = 0 ; t_Index < a_KeyIndex ; t_Index ++ )
  7787. {
  7788. DebugMacro3(
  7789. WmiDebugLog :: s_WmiDebugLog->Write (
  7790. L" "
  7791. ) ;
  7792. )
  7793. }
  7794. for ( t_Index = 0 ; t_Index < a_DisjunctionSetToTestCount ; t_Index ++ )
  7795. {
  7796. DebugMacro3(
  7797. WmiDebugLog :: s_WmiDebugLog->Write (
  7798. L"%lu", a_DisjunctionSetToTest [ t_Index ] ? 1 : 0
  7799. ) ;
  7800. )
  7801. }
  7802. DebugMacro3(
  7803. WmiDebugLog :: s_WmiDebugLog->Write (
  7804. L"\n"
  7805. ) ;
  7806. )
  7807. for ( t_Index = 0 ; t_Index < a_DisjunctionSetToTestCount ; t_Index ++ )
  7808. {
  7809. for ( ULONG t_InnerIndex = 0 ; t_InnerIndex < a_KeyIndex ; t_InnerIndex ++ )
  7810. {
  7811. DebugMacro3(
  7812. WmiDebugLog :: s_WmiDebugLog->Write (
  7813. L" "
  7814. ) ;
  7815. )
  7816. }
  7817. Conjunctions *t_Disjunction = a_Disjunctions->GetDisjunction ( t_Index ) ;
  7818. if ( t_Disjunction )
  7819. {
  7820. if (WmiRangeNode * range = t_Disjunction->GetRange ( a_KeyIndex ))
  7821. {
  7822. range->Print () ;
  7823. DebugMacro3(
  7824. WmiDebugLog :: s_WmiDebugLog->Write (
  7825. L"\n"
  7826. ) ;
  7827. )
  7828. }
  7829. }
  7830. }
  7831. }
  7832. /******************************************************************************
  7833. *
  7834. * Name:
  7835. *
  7836. *
  7837. * Description:
  7838. *
  7839. *
  7840. *****************************************************************************/
  7841. void PrintSortedRange (
  7842. Disjunctions *a_Disjunctions ,
  7843. ULONG a_DisjunctionSetToTestCount ,
  7844. ULONG *a_DisjunctionSetToTest ,
  7845. ULONG *a_OriginToSorted ,
  7846. ULONG a_KeyIndex ,
  7847. WmiRangeNode **a_RangeTable
  7848. )
  7849. {
  7850. for ( ULONG t_Index = 0 ; t_Index < a_DisjunctionSetToTestCount ; t_Index ++ )
  7851. {
  7852. if ( a_RangeTable [ t_Index ] )
  7853. {
  7854. for ( ULONG t_InnerIndex = 0 ; t_InnerIndex < a_KeyIndex ; t_InnerIndex ++ )
  7855. {
  7856. DebugMacro3(
  7857. WmiDebugLog :: s_WmiDebugLog->Write (
  7858. L"%lu ", t_Index
  7859. ) ;
  7860. )
  7861. }
  7862. if ( a_DisjunctionSetToTest [ a_OriginToSorted [ t_Index ] ] )
  7863. {
  7864. DebugMacro3(
  7865. WmiDebugLog :: s_WmiDebugLog->Write (
  7866. L"In "
  7867. ) ;
  7868. )
  7869. }
  7870. else
  7871. {
  7872. DebugMacro3(
  7873. WmiDebugLog :: s_WmiDebugLog->Write (
  7874. L"Out "
  7875. ) ;
  7876. )
  7877. }
  7878. a_RangeTable [ t_Index ]->Print () ;
  7879. DebugMacro3(
  7880. WmiDebugLog :: s_WmiDebugLog->Write (
  7881. L"\n"
  7882. ) ;
  7883. )
  7884. }
  7885. }
  7886. }
  7887. /******************************************************************************
  7888. *
  7889. * Name:
  7890. *
  7891. *
  7892. * Description:
  7893. *
  7894. *
  7895. *****************************************************************************/
  7896. void PrintOverlap (
  7897. ULONG a_DisjunctionSetToTestCount ,
  7898. ULONG *a_DisjunctionSetToTest ,
  7899. ULONG *a_SortedDisjunctionSetToTest ,
  7900. ULONG *a_OverlappingIndex ,
  7901. ULONG a_KeyIndex
  7902. )
  7903. {
  7904. for ( ULONG t_Index = 0 ; t_Index < a_KeyIndex ; t_Index ++ )
  7905. {
  7906. DebugMacro3(
  7907. WmiDebugLog :: s_WmiDebugLog->Write (
  7908. L" "
  7909. ) ;
  7910. )
  7911. }
  7912. for ( t_Index = 0 ; t_Index < a_DisjunctionSetToTestCount ; t_Index ++ )
  7913. {
  7914. DebugMacro3(
  7915. if ( a_DisjunctionSetToTest [ t_Index ] )
  7916. {
  7917. WmiDebugLog :: s_WmiDebugLog->Write (
  7918. L"%lu ", a_OverlappingIndex [ t_Index ]
  7919. ) ;
  7920. }
  7921. else
  7922. {
  7923. WmiDebugLog :: s_WmiDebugLog->Write (
  7924. L"X "
  7925. ) ;
  7926. }
  7927. )
  7928. }
  7929. DebugMacro3(
  7930. WmiDebugLog :: s_WmiDebugLog->Write (
  7931. L"\n"
  7932. ) ;
  7933. )
  7934. }
  7935. /******************************************************************************
  7936. *
  7937. * Name:
  7938. *
  7939. *
  7940. * Description:
  7941. *
  7942. *
  7943. *****************************************************************************/
  7944. void QueryPreprocessor :: RecursiveQuickSort (
  7945. WmiRangeNode **a_Array ,
  7946. ULONG *a_UnsortedOrder ,
  7947. ULONG a_Lower ,
  7948. ULONG a_Upper
  7949. )
  7950. {
  7951. if ( a_Lower <= a_Upper )
  7952. {
  7953. ULONG t_LeftIndex = a_Lower ;
  7954. ULONG t_RightIndex = a_Upper ;
  7955. while ( true )
  7956. {
  7957. while ( ( t_LeftIndex < t_RightIndex ) && CompareLessOrEqualRangeNode ( a_Array [ t_LeftIndex ] , a_Array [ a_Lower - 1 ] ) )
  7958. {
  7959. t_LeftIndex ++ ;
  7960. }
  7961. while ( ( t_LeftIndex < t_RightIndex ) && CompareLessOrEqualRangeNode ( a_Array [ a_Lower - 1 ] , a_Array [ t_RightIndex ] ) )
  7962. {
  7963. t_RightIndex -- ;
  7964. }
  7965. if ( t_LeftIndex < t_RightIndex )
  7966. {
  7967. WmiRangeNode *t_Temp = a_Array [ t_LeftIndex ] ;
  7968. a_Array [ t_LeftIndex ] = a_Array [ t_RightIndex ] ;
  7969. a_Array [ t_RightIndex ] = t_Temp ;
  7970. ULONG t_Val = a_UnsortedOrder [ t_LeftIndex ] ;
  7971. a_UnsortedOrder [ t_LeftIndex ] = a_UnsortedOrder [ t_RightIndex ];
  7972. a_UnsortedOrder [ t_RightIndex ] = t_Val ;
  7973. }
  7974. else
  7975. {
  7976. break ;
  7977. }
  7978. }
  7979. LONG t_Compare = CompareLessOrEqualRangeNode ( a_Array [ t_LeftIndex ] , a_Array [ a_Lower - 1 ] ) ;
  7980. if ( t_Compare )
  7981. {
  7982. WmiRangeNode *t_Temp = a_Array [ t_LeftIndex ] ;
  7983. a_Array [ t_LeftIndex ] = a_Array [ a_Lower - 1 ] ;
  7984. a_Array [ a_Lower - 1 ] = t_Temp ;
  7985. ULONG t_Val = a_UnsortedOrder [ t_LeftIndex ] ;
  7986. a_UnsortedOrder [ t_LeftIndex ] = a_UnsortedOrder [ a_Lower - 1 ];
  7987. a_UnsortedOrder [ a_Lower - 1 ] = t_Val ;
  7988. }
  7989. RecursiveQuickSort (
  7990. a_Array ,
  7991. a_UnsortedOrder ,
  7992. a_Lower ,
  7993. t_LeftIndex - 1
  7994. ) ;
  7995. RecursiveQuickSort (
  7996. a_Array ,
  7997. a_UnsortedOrder ,
  7998. t_LeftIndex + 1 ,
  7999. a_Upper
  8000. ) ;
  8001. }
  8002. }
  8003. /******************************************************************************
  8004. *
  8005. * Name:
  8006. *
  8007. *
  8008. * Description:
  8009. *
  8010. *
  8011. *****************************************************************************/
  8012. void QueryPreprocessor :: QuickSort (
  8013. WmiRangeNode **a_Array ,
  8014. ULONG *a_UnsortedOrder ,
  8015. ULONG a_Size
  8016. )
  8017. {
  8018. RecursiveQuickSort ( a_Array , a_UnsortedOrder , 1 , a_Size - 1 ) ;
  8019. }
  8020. /******************************************************************************
  8021. *
  8022. * Name:
  8023. *
  8024. *
  8025. * Description:
  8026. *
  8027. *
  8028. *****************************************************************************/
  8029. void QueryPreprocessor :: SortRanges (
  8030. ULONG t_DisjunctionCount ,
  8031. ULONG *t_OriginToSorted ,
  8032. WmiRangeNode **t_RangeTable
  8033. )
  8034. {
  8035. QuickSort ( t_RangeTable , t_OriginToSorted , t_DisjunctionCount ) ;
  8036. }
  8037. /******************************************************************************
  8038. *
  8039. * Name:
  8040. *
  8041. *
  8042. * Description:
  8043. *
  8044. *
  8045. *****************************************************************************/
  8046. WmiTriState QueryPreprocessor :: RemoveOverlaps (
  8047. ULONG *a_DisjunctionSetToTest ,
  8048. ULONG a_DisjunctionCount ,
  8049. ULONG *a_OverlappingIndex ,
  8050. ULONG *a_OriginToSorted ,
  8051. WmiRangeNode **a_RangeTable
  8052. )
  8053. {
  8054. WmiTriState t_Status = :: State_True ;
  8055. /*
  8056. * Remove Overlaps
  8057. */
  8058. ULONG t_InnerIndex = 0 ;
  8059. ULONG t_OuterIndex = 1 ;
  8060. while ( ( t_Status != :: State_Error ) && ( t_OuterIndex < a_DisjunctionCount ) )
  8061. {
  8062. WmiRangeNode *t_LeftRange = a_RangeTable [ t_OuterIndex ] ;
  8063. WmiRangeNode *t_RightRange = a_RangeTable [ t_InnerIndex ] ;
  8064. if ( a_OverlappingIndex [ t_OuterIndex ] != a_OverlappingIndex [ t_InnerIndex ] )
  8065. {
  8066. if ( t_LeftRange && t_RightRange )
  8067. {
  8068. if ( ( t_LeftRange->GetType () == TypeId_WmiStringRangeNode ) && ( t_RightRange->GetType () == TypeId_WmiStringRangeNode ) )
  8069. {
  8070. WmiStringRangeNode *t_LeftString = ( WmiStringRangeNode * ) t_LeftRange ;
  8071. WmiStringRangeNode *t_RightString = ( WmiStringRangeNode * ) t_RightRange ;
  8072. WmiStringRangeNode *t_OverLap = NULL ;
  8073. t_Status = t_LeftString->GetOverlappingRange ( *t_RightString , t_OverLap ) ;
  8074. if ( t_Status == :: State_True )
  8075. {
  8076. DebugMacro3(
  8077. WmiDebugLog :: s_WmiDebugLog->Write (
  8078. L"Overlap\n"
  8079. ) ;
  8080. )
  8081. delete a_RangeTable [ t_OuterIndex ] ;
  8082. a_RangeTable [ t_OuterIndex ] = t_OverLap ;
  8083. delete a_RangeTable [ t_InnerIndex ] ;
  8084. a_RangeTable [ t_InnerIndex ] = NULL ;
  8085. a_OverlappingIndex [ t_InnerIndex ] = t_OuterIndex ;
  8086. }
  8087. else
  8088. {
  8089. DebugMacro3(
  8090. WmiDebugLog :: s_WmiDebugLog->Write (
  8091. L"Non Overlap\n"
  8092. ) ;
  8093. )
  8094. }
  8095. }
  8096. else if ( ( t_LeftRange->GetType () == TypeId_WmiUnsignedIntegerRangeNode ) && ( t_RightRange->GetType () == TypeId_WmiUnsignedIntegerRangeNode ) )
  8097. {
  8098. WmiUnsignedIntegerRangeNode *t_LeftInteger = ( WmiUnsignedIntegerRangeNode * ) t_LeftRange ;
  8099. WmiUnsignedIntegerRangeNode *t_RightInteger = ( WmiUnsignedIntegerRangeNode * ) t_RightRange ;
  8100. WmiUnsignedIntegerRangeNode *t_OverLap = NULL ;
  8101. t_Status = t_LeftInteger->GetOverlappingRange ( *t_RightInteger , t_OverLap ) ;
  8102. if ( t_Status == :: State_True )
  8103. {
  8104. DebugMacro3(
  8105. WmiDebugLog :: s_WmiDebugLog->Write (
  8106. L"Overlap\n"
  8107. ) ;
  8108. )
  8109. delete a_RangeTable [ t_OuterIndex ] ;
  8110. a_RangeTable [ t_OuterIndex ] = t_OverLap ;
  8111. delete a_RangeTable [ t_InnerIndex ] ;
  8112. a_RangeTable [ t_InnerIndex ] = NULL ;
  8113. a_OverlappingIndex [ t_InnerIndex ] = t_OuterIndex ;
  8114. }
  8115. else
  8116. {
  8117. DebugMacro3(
  8118. WmiDebugLog :: s_WmiDebugLog->Write (
  8119. L"Non Overlap\n"
  8120. ) ;
  8121. )
  8122. }
  8123. }
  8124. else if ( ( t_LeftRange->GetType () == TypeId_WmiSignedIntegerRangeNode ) && ( t_RightRange->GetType () == TypeId_WmiSignedIntegerRangeNode ) )
  8125. {
  8126. WmiSignedIntegerRangeNode *t_LeftInteger = ( WmiSignedIntegerRangeNode * ) t_LeftRange ;
  8127. WmiSignedIntegerRangeNode *t_RightInteger = ( WmiSignedIntegerRangeNode * ) t_RightRange ;
  8128. WmiSignedIntegerRangeNode *t_OverLap = NULL ;
  8129. t_Status = t_LeftInteger->GetOverlappingRange ( *t_RightInteger , t_OverLap ) ;
  8130. if ( t_Status == :: State_True )
  8131. {
  8132. DebugMacro3(
  8133. WmiDebugLog :: s_WmiDebugLog->Write (
  8134. L"Overlap\n"
  8135. ) ;
  8136. )
  8137. delete a_RangeTable [ t_OuterIndex ] ;
  8138. a_RangeTable [ t_OuterIndex ] = t_OverLap ;
  8139. delete a_RangeTable [ t_InnerIndex ] ;
  8140. a_RangeTable [ t_InnerIndex ] = NULL ;
  8141. a_OverlappingIndex [ t_InnerIndex ] = t_OuterIndex ;
  8142. }
  8143. else
  8144. {
  8145. DebugMacro3(
  8146. WmiDebugLog :: s_WmiDebugLog->Write (
  8147. L"Non Overlap\n"
  8148. ) ;
  8149. )
  8150. }
  8151. }
  8152. else
  8153. {
  8154. // Failure
  8155. t_Status = :: State_Error ;
  8156. }
  8157. }
  8158. }
  8159. t_InnerIndex ++ ;
  8160. t_OuterIndex ++ ;
  8161. }
  8162. for ( LONG t_Index = a_DisjunctionCount - 1 ; t_Index >= 0 ; t_Index -- )
  8163. {
  8164. if ( t_Index < a_OverlappingIndex [ t_Index ] )
  8165. {
  8166. a_OverlappingIndex [ t_Index ] = a_OverlappingIndex [ a_OverlappingIndex [ t_Index ] ] ;
  8167. }
  8168. }
  8169. return t_Status ;
  8170. }
  8171. /******************************************************************************
  8172. *
  8173. * Name:
  8174. *
  8175. *
  8176. * Description:
  8177. *
  8178. *
  8179. *****************************************************************************/
  8180. WmiTriState QueryPreprocessor :: RecursivePartitionSet (
  8181. Disjunctions *a_Disjunctions ,
  8182. PartitionSet *&a_Partition ,
  8183. ULONG a_DisjunctionSetToTestCount ,
  8184. ULONG *a_DisjunctionSetToTest ,
  8185. ULONG a_KeyIndex
  8186. )
  8187. {
  8188. WmiTriState t_Status = :: State_True ;
  8189. if ( a_KeyIndex < a_Disjunctions->GetConjunctionCount () )
  8190. {
  8191. ULONG *t_OverlappingIndex = new ULONG [ a_DisjunctionSetToTestCount ] ;
  8192. wmilib::auto_buffer<ULONG> autoOverlappingIndex(t_OverlappingIndex);
  8193. ULONG *t_OriginToSorted = new ULONG [ a_DisjunctionSetToTestCount ] ;
  8194. wmilib::auto_buffer<ULONG> autoOriginToSorted(t_OriginToSorted);
  8195. WmiRangeNode **t_RangeTable = new WmiRangeNode * [ a_DisjunctionSetToTestCount ] ;
  8196. wmilib::auto_buffer<WmiRangeNode *> autoRangeTable(t_RangeTable);
  8197. if ( t_OverlappingIndex && t_OriginToSorted && t_RangeTable )
  8198. {
  8199. for ( ULONG t_Index = 0 ; t_Index < a_DisjunctionSetToTestCount ; t_Index ++ )
  8200. {
  8201. Conjunctions *t_Disjunction = a_Disjunctions->GetDisjunction ( a_DisjunctionSetToTest [ t_Index ] ) ;
  8202. if (NULL == t_Disjunction)
  8203. {
  8204. t_Status = ::State_Error;
  8205. break;
  8206. }
  8207. t_RangeTable [ t_Index ] = ( WmiRangeNode * ) t_Disjunction->GetRange ( a_KeyIndex )->Copy () ;
  8208. t_OverlappingIndex [ t_Index ] = t_Index ;
  8209. t_OriginToSorted [ t_Index ] = t_Index ;
  8210. }
  8211. // Sort Partitions
  8212. if ( t_Status != :: State_Error )
  8213. {
  8214. SortRanges (
  8215. a_DisjunctionSetToTestCount ,
  8216. t_OriginToSorted ,
  8217. t_RangeTable
  8218. ) ;
  8219. t_Status = RemoveOverlaps (
  8220. a_DisjunctionSetToTest ,
  8221. a_DisjunctionSetToTestCount ,
  8222. t_OverlappingIndex ,
  8223. t_OriginToSorted ,
  8224. t_RangeTable
  8225. ) ;
  8226. }
  8227. if ( t_Status != :: State_Error )
  8228. {
  8229. ULONG t_PartitionCount = 0 ;
  8230. for ( t_Index = 0 ; t_Index < a_DisjunctionSetToTestCount ; t_Index ++ )
  8231. {
  8232. if ( t_RangeTable [ t_Index ] )
  8233. {
  8234. t_PartitionCount ++ ;
  8235. }
  8236. }
  8237. t_Status = a_Partition->Initialize ( t_PartitionCount ) ;
  8238. if ( t_Status == :: State_True )
  8239. {
  8240. ULONG t_PartitionIndex = 0 ;
  8241. for ( t_Index = 0 ; t_Index < a_DisjunctionSetToTestCount; t_Index ++ )
  8242. {
  8243. WmiRangeNode *t_Range = t_RangeTable [ t_Index ] ;
  8244. if ( t_Range )
  8245. {
  8246. PartitionSet *t_Partition = new PartitionSet ;
  8247. if ( t_Partition )
  8248. {
  8249. a_Partition->SetPartition ( t_PartitionIndex , t_Partition ) ;
  8250. WmiRangeNode *t_Copy = ( WmiRangeNode * ) t_Range->Copy () ;
  8251. if ( t_Copy )
  8252. {
  8253. t_Partition->SetRange ( t_Copy ) ;
  8254. t_Partition->SetKeyIndex ( a_KeyIndex ) ;
  8255. t_PartitionIndex ++ ;
  8256. }
  8257. else
  8258. {
  8259. t_Status = :: State_Error ;
  8260. break ;
  8261. }
  8262. }
  8263. else
  8264. {
  8265. t_Status = :: State_Error ;
  8266. break ;
  8267. }
  8268. }
  8269. }
  8270. }
  8271. if ( t_Status == :: State_True )
  8272. {
  8273. /*
  8274. * Outer Index is the range order
  8275. */
  8276. ULONG t_PartitionIndex = 0 ;
  8277. /*
  8278. * Array allocation has max defined by function arg.
  8279. */
  8280. ULONG *t_DisjunctionSetToTest = new ULONG [ a_DisjunctionSetToTestCount ] ;
  8281. if ( t_DisjunctionSetToTest )
  8282. {
  8283. ULONG t_OuterIndex = 0 ;
  8284. while ( t_Status && ( t_OuterIndex < a_DisjunctionSetToTestCount ) )
  8285. {
  8286. BOOL t_Found = FALSE ;
  8287. ULONG t_DisjunctionSetToTestCount = 0 ;
  8288. if ( t_RangeTable [ t_OuterIndex ] )
  8289. {
  8290. /*
  8291. * Inner index matches the overlaps
  8292. */
  8293. LONG t_InnerIndex = t_OuterIndex ;
  8294. while ( t_InnerIndex >= 0 )
  8295. {
  8296. if ( t_OverlappingIndex [ t_OuterIndex ] == t_OverlappingIndex [ t_InnerIndex ] )
  8297. {
  8298. t_DisjunctionSetToTest [ t_DisjunctionSetToTestCount ] = a_DisjunctionSetToTest [ t_OriginToSorted [ t_InnerIndex ] ] ;
  8299. t_DisjunctionSetToTestCount ++ ;
  8300. t_Found = TRUE ;
  8301. }
  8302. else
  8303. {
  8304. break ;
  8305. }
  8306. t_InnerIndex -- ;
  8307. }
  8308. }
  8309. if ( t_Found )
  8310. {
  8311. PartitionSet *t_Partition = a_Partition->GetPartition ( t_PartitionIndex ) ;
  8312. if ( t_Partition )
  8313. {
  8314. t_Status = RecursivePartitionSet (
  8315. a_Disjunctions ,
  8316. t_Partition ,
  8317. t_DisjunctionSetToTestCount ,
  8318. t_DisjunctionSetToTest ,
  8319. a_KeyIndex + 1
  8320. ) ;
  8321. t_PartitionIndex ++ ;
  8322. }
  8323. }
  8324. t_OuterIndex ++ ;
  8325. }
  8326. delete [] t_DisjunctionSetToTest ;
  8327. }
  8328. else
  8329. {
  8330. t_Status = :: State_Error ;
  8331. }
  8332. }
  8333. }
  8334. else
  8335. {
  8336. t_Status = :: State_Error ;
  8337. }
  8338. for ( t_Index = 0 ; t_Index < a_DisjunctionSetToTestCount ; t_Index ++ )
  8339. {
  8340. if ( t_RangeTable [ t_Index ] )
  8341. {
  8342. delete t_RangeTable [ t_Index ] ;
  8343. }
  8344. }
  8345. }
  8346. else
  8347. {
  8348. t_Status = :: State_Error ;
  8349. }
  8350. }
  8351. return t_Status ;
  8352. }
  8353. /******************************************************************************
  8354. *
  8355. * Name:
  8356. *
  8357. *
  8358. * Description:
  8359. *
  8360. *
  8361. *****************************************************************************/
  8362. WmiTriState QueryPreprocessor :: CreatePartitionSet ( Disjunctions *a_Disjunctions , PartitionSet *&a_Partition )
  8363. {
  8364. WmiTriState t_Status = :: State_False ;
  8365. a_Partition = NULL ;
  8366. ULONG t_DisjunctionCount = a_Disjunctions->GetDisjunctionCount () ;
  8367. ULONG *t_DisjunctionSetToTest = new ULONG [ t_DisjunctionCount ] ;
  8368. if ( t_DisjunctionSetToTest )
  8369. {
  8370. for ( ULONG t_Index = 0 ; t_Index < t_DisjunctionCount ; t_Index ++ )
  8371. {
  8372. t_DisjunctionSetToTest [ t_Index ] = t_Index ;
  8373. }
  8374. a_Partition = new PartitionSet ;
  8375. if ( a_Partition )
  8376. {
  8377. t_Status = RecursivePartitionSet (
  8378. a_Disjunctions ,
  8379. a_Partition ,
  8380. t_DisjunctionCount ,
  8381. t_DisjunctionSetToTest ,
  8382. 0
  8383. ) ;
  8384. }
  8385. else
  8386. {
  8387. t_Status = :: State_Error ;
  8388. }
  8389. delete [] t_DisjunctionSetToTest ;
  8390. }
  8391. else
  8392. {
  8393. t_Status = :: State_Error ;
  8394. }
  8395. return t_Status;
  8396. }
  8397. /******************************************************************************
  8398. *
  8399. * Name:
  8400. *
  8401. *
  8402. * Description:
  8403. *
  8404. *
  8405. *****************************************************************************/
  8406. QueryPreprocessor :: QuadState QueryPreprocessor :: PreProcess (
  8407. void *a_Context ,
  8408. IWbemQuery *a_QueryAnalysis ,
  8409. WmiTreeNode *&a_Root
  8410. )
  8411. {
  8412. QuadState t_State = State_Error ;
  8413. SWbemRpnEncodedQuery *t_Expression = NULL ;
  8414. HRESULT t_Result = a_QueryAnalysis->GetAnalysis (
  8415. WMIQ_ANALYSIS_RPN_SEQUENCE ,
  8416. 0 ,
  8417. ( void ** ) & t_Expression
  8418. ) ;
  8419. if ( SUCCEEDED ( t_Result ) )
  8420. {
  8421. BOOL t_Status = Evaluate (
  8422. a_Context ,
  8423. ( t_Expression->m_ppRpnWhereClause ) ,
  8424. ( t_Expression->m_uWhereClauseSize ) ,
  8425. & a_Root
  8426. ) ;
  8427. if ( t_Status )
  8428. {
  8429. t_State = State_True ;
  8430. PrintTree ( a_Root ) ;
  8431. t_State = DisjunctiveNormalForm ( a_Root ) ;
  8432. PrintTree ( a_Root ) ;
  8433. }
  8434. a_QueryAnalysis->FreeMemory ( t_Expression ) ;
  8435. }
  8436. return t_State ;
  8437. }
  8438. /******************************************************************************
  8439. *
  8440. * Name:
  8441. *
  8442. *
  8443. * Description:
  8444. *
  8445. *
  8446. *****************************************************************************/
  8447. QueryPreprocessor :: QuadState QueryPreprocessor :: Query (
  8448. BSTR a_Query ,
  8449. IWbemQuery *a_QueryAnalysis
  8450. )
  8451. {
  8452. QuadState t_State = State_Error ;
  8453. ULONG t_Array [] = {
  8454. WMIQ_LF1_BASIC_SELECT ,
  8455. WMIQ_LF2_CLASS_NAME_IN_QUERY ,
  8456. WMIQ_LF3_STRING_CASE_FUNCTIONS ,
  8457. WMIQ_LF4_PROP_TO_PROP_TESTS ,
  8458. WMIQ_LF8_ISA ,
  8459. WMIQ_LF9_THIS ,
  8460. WMIQ_LF26_LIKE
  8461. } ;
  8462. ULONG t_ArraySize = sizeof ( t_Array ) / sizeof ( ULONG ) ;
  8463. HRESULT t_Result = a_QueryAnalysis->SetLanguageFeatures (
  8464. 0 ,
  8465. t_ArraySize ,
  8466. t_Array
  8467. ) ;
  8468. if ( SUCCEEDED ( t_Result ) )
  8469. {
  8470. t_Result = a_QueryAnalysis->Parse ( L"WQL" , a_Query , 0 ) ;
  8471. if ( SUCCEEDED ( t_Result ) )
  8472. {
  8473. t_State = State_True ;
  8474. }
  8475. }
  8476. return t_State ;
  8477. }
  8478. /******************************************************************************
  8479. *
  8480. * Name:
  8481. *
  8482. *
  8483. * Description:
  8484. *
  8485. *
  8486. *****************************************************************************/
  8487. QueryPreprocessor :: QueryPreprocessor ()
  8488. {
  8489. }
  8490. /******************************************************************************
  8491. *
  8492. * Name:
  8493. *
  8494. *
  8495. * Description:
  8496. *
  8497. *
  8498. *****************************************************************************/
  8499. QueryPreprocessor :: ~QueryPreprocessor ()
  8500. {
  8501. }
  8502. /******************************************************************************
  8503. *
  8504. * Name:
  8505. *
  8506. *
  8507. * Description:
  8508. *
  8509. *
  8510. *****************************************************************************/
  8511. #define SYSTEM_PROPERTY_DYNASTY L"__DYNASTY"
  8512. #define SYSTEM_PROPERTY_DERIVATION L"__DERIVATION"
  8513. #define SYSTEM_PROPERTY_GENUS L"__GENUS"
  8514. #define SYSTEM_PROPERTY_NAMESPACE L"__NAMESPACE"
  8515. #define SYSTEM_PROPERTY_PROPERTY_COUNT L"__PROPERTY_COUNT"
  8516. #define SYSTEM_PROPERTY_SERVER L"__SERVER"
  8517. #define SYSTEM_PROPERTY_RELPATH L"__RELPATH"
  8518. #define SYSTEM_PROPERTY_PATH L"__PATH"
  8519. #define SYSTEM_PROPERTY_CLASS L"__CLASS"
  8520. #define SYSTEM_PROPERTY_SUPERCLASS L"__SUPERCLASS"
  8521. #define SYSTEM_PROPERTY_THIS L"__THIS"
  8522. /******************************************************************************
  8523. *
  8524. * Name:
  8525. *
  8526. *
  8527. * Description:
  8528. *
  8529. *
  8530. *****************************************************************************/
  8531. WmiTreeNode *QueryPreprocessor :: AllocTypeNode (
  8532. void *a_Context ,
  8533. BSTR a_PropertyName ,
  8534. VARIANT &a_Variant ,
  8535. WmiValueNode :: WmiValueFunction a_PropertyFunction ,
  8536. WmiValueNode :: WmiValueFunction a_ConstantFunction ,
  8537. WmiTreeNode *a_Parent
  8538. )
  8539. {
  8540. WmiTreeNode *t_Node = NULL ;
  8541. VARTYPE t_VarType = VT_NULL ;
  8542. if ( *a_PropertyName == L'_' )
  8543. {
  8544. // System property
  8545. if ( wbem_wcsicmp ( a_PropertyName , SYSTEM_PROPERTY_SUPERCLASS ) == 0 )
  8546. {
  8547. t_Node = new WmiStringNode (
  8548. a_PropertyName ,
  8549. a_Variant.bstrVal ,
  8550. a_PropertyFunction ,
  8551. a_ConstantFunction ,
  8552. 0xFFFFFFFF ,
  8553. a_Parent
  8554. ) ;
  8555. }
  8556. else if ( wbem_wcsicmp ( a_PropertyName , SYSTEM_PROPERTY_THIS ) == 0 )
  8557. {
  8558. t_Node = new WmiStringNode (
  8559. a_PropertyName ,
  8560. a_Variant.bstrVal ,
  8561. a_PropertyFunction ,
  8562. a_ConstantFunction ,
  8563. 0xFFFFFFFF ,
  8564. a_Parent
  8565. ) ;
  8566. }
  8567. else if ( wbem_wcsicmp ( a_PropertyName , SYSTEM_PROPERTY_CLASS ) == 0 )
  8568. {
  8569. t_Node = new WmiStringNode (
  8570. a_PropertyName ,
  8571. a_Variant.bstrVal ,
  8572. a_PropertyFunction ,
  8573. a_ConstantFunction ,
  8574. 0xFFFFFFFF ,
  8575. a_Parent
  8576. ) ;
  8577. }
  8578. }
  8579. if ( t_Node && !t_Node->IsValid())
  8580. {
  8581. delete t_Node;
  8582. t_Node = 0;
  8583. }
  8584. return t_Node ;
  8585. }