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.

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