Source code of Windows XP (NT5)
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.

1583 lines
31 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992-1999.
  5. //
  6. // File: Restrict.hxx
  7. //
  8. // Contents: C++ wrapper(s) for restrictions.
  9. //
  10. // History: 31-Dec-93 KyleP Created
  11. // 28-Jul-94 KyleP Hand marshalling
  12. // 05-Apr-95 t-ColinB Added a SetValue to CPropertyRestriction
  13. //
  14. // Notes: These C++ wrappers are a bit of a hack. They are
  15. // dependent on the layout of the matching C structures.
  16. // Inheritance from C structures cannot be used directly
  17. // because MIDL doesn't support C++ style inheritance,
  18. // and these structures are defined along with their
  19. // respective Ole interfaces in .idl files.
  20. //
  21. // No virtual methods (even virtual destructors) are
  22. // allowed because they change the layout of the class
  23. // in C++. Luckily, the class hierarchies below are
  24. // quite flat. Virtual methods are simulated with
  25. // switch statements in parent classes.
  26. //
  27. // In C, all structures must be allocated via CoTaskMemAlloc.
  28. // This is the only common allocator for Ole.
  29. //
  30. //--------------------------------------------------------------------------
  31. #if !defined( __RESTRICT_HXX__ )
  32. #define __RESTRICT_HXX__
  33. #if _MSC_VER > 1000
  34. #pragma once
  35. #endif
  36. #include <query.h>
  37. #include <stgvar.hxx>
  38. //
  39. // The OFFSETS_MATCH macro is used to verify structure offsets between
  40. // C++ structures and their corresponding C structures. 0 Cannot be used
  41. // as pointer because of special treatment of casts to 0 in C++
  42. //
  43. #define OFFSETS_MATCH( class1, field1, class2, field2 ) \
  44. ( (ULONG_PTR)&((class1 *)10)->field1 == \
  45. (ULONG_PTR)&((class2 *)10)->field2 )
  46. //
  47. // Forward declarations
  48. //
  49. class CNodeRestriction;
  50. class PSerStream;
  51. class PDeSerStream;
  52. //+-------------------------------------------------------------------------
  53. //
  54. // Class: CFullPropertySpec
  55. //
  56. // Purpose: Describes full (PropertySet\Property) name of a property.
  57. //
  58. // History: 08-Jan-93 KyleP Created
  59. //
  60. //--------------------------------------------------------------------------
  61. class CFullPropSpec
  62. {
  63. public:
  64. //
  65. // Constructors
  66. //
  67. CFullPropSpec();
  68. CFullPropSpec( GUID const & guidPropSet, PROPID pidProperty );
  69. CFullPropSpec( GUID const & guidPropSet, WCHAR const * wcsProperty );
  70. //
  71. // Validity check
  72. //
  73. inline BOOL IsValid() const;
  74. //
  75. // Copy constructors/assignment/clone
  76. //
  77. CFullPropSpec( CFullPropSpec const & Property );
  78. CFullPropSpec & operator=( CFullPropSpec const & Property );
  79. //
  80. // Destructor
  81. //
  82. ~CFullPropSpec();
  83. //
  84. // Memory allocation
  85. //
  86. void * operator new( size_t size );
  87. inline void * operator new( size_t size, void * p );
  88. void operator delete( void * p );
  89. #if _MSC_VER >= 1200
  90. inline void operator delete( void * p, void * pp );
  91. #endif
  92. //
  93. // C/C++ conversion
  94. //
  95. inline FULLPROPSPEC * CastToStruct();
  96. inline FULLPROPSPEC const * CastToStruct() const;
  97. //
  98. // Serialization
  99. //
  100. void Marshall( PSerStream & stm ) const;
  101. CFullPropSpec( PDeSerStream & stm );
  102. //
  103. // Comparators
  104. //
  105. int operator==( CFullPropSpec const & prop ) const;
  106. int operator!=( CFullPropSpec const & prop ) const;
  107. //
  108. // Member variable access
  109. //
  110. inline void SetPropSet( GUID const & guidPropSet );
  111. inline GUID const & GetPropSet() const;
  112. void SetProperty( PROPID pidProperty );
  113. BOOL SetProperty( WCHAR const * wcsProperty );
  114. inline WCHAR const * GetPropertyName() const;
  115. inline PROPID GetPropertyPropid() const;
  116. inline PROPSPEC GetPropSpec() const;
  117. inline BOOL IsPropertyName() const;
  118. inline BOOL IsPropertyPropid() const;
  119. # ifdef CIEXTMODE
  120. void CiExtDump(void *ciExtSelf);
  121. # endif
  122. private:
  123. GUID _guidPropSet;
  124. PROPSPEC _psProperty;
  125. };
  126. inline
  127. int CFullPropSpec::operator==( CFullPropSpec const & prop ) const
  128. {
  129. if ( prop._psProperty.ulKind != _psProperty.ulKind )
  130. return 0;
  131. switch( _psProperty.ulKind )
  132. {
  133. case PRSPEC_PROPID:
  134. if ( GetPropertyPropid() != prop.GetPropertyPropid() )
  135. return 0;
  136. break;
  137. case PRSPEC_LPWSTR:
  138. if ( _wcsicmp( GetPropertyName(), prop.GetPropertyName() ) != 0 )
  139. return 0;
  140. break;
  141. default:
  142. return 0;
  143. }
  144. return prop._guidPropSet == _guidPropSet;
  145. }
  146. inline
  147. int CFullPropSpec::operator!=( CFullPropSpec const & prop ) const
  148. {
  149. if (*this == prop)
  150. return( 0 );
  151. else
  152. return( 1 );
  153. }
  154. inline
  155. CFullPropSpec::~CFullPropSpec()
  156. {
  157. if ( _psProperty.ulKind == PRSPEC_LPWSTR &&
  158. _psProperty.lpwstr )
  159. {
  160. CoTaskMemFree( _psProperty.lpwstr );
  161. }
  162. }
  163. //+-------------------------------------------------------------------------
  164. //
  165. // Member: CFullPropSpec::CFullPropSpec, public
  166. //
  167. // Synopsis: Construct name based propspec
  168. //
  169. // Arguments: [guidPropSet] -- Property set
  170. // [wcsProperty] -- Property
  171. //
  172. // History: 22-Jun-93 KyleP Created
  173. //
  174. //--------------------------------------------------------------------------
  175. inline
  176. CFullPropSpec::CFullPropSpec( GUID const & guidPropSet,
  177. WCHAR const * wcsProperty )
  178. : _guidPropSet( guidPropSet )
  179. {
  180. _psProperty.ulKind = PRSPEC_PROPID;
  181. SetProperty( wcsProperty );
  182. }
  183. //+-------------------------------------------------------------------------
  184. //
  185. // Member: CFullPropSpec::CFullPropSpec, public
  186. //
  187. // Synopsis: Construct propid based propspec
  188. //
  189. // Arguments: [guidPropSet] -- Property set
  190. // [pidProperty] -- Property
  191. //
  192. // History: 22-Jun-93 KyleP Created
  193. //
  194. //--------------------------------------------------------------------------
  195. inline
  196. CFullPropSpec::CFullPropSpec( GUID const & guidPropSet, PROPID pidProperty )
  197. : _guidPropSet( guidPropSet )
  198. {
  199. _psProperty.ulKind = PRSPEC_PROPID;
  200. _psProperty.propid = pidProperty;
  201. }
  202. //+-------------------------------------------------------------------------
  203. //
  204. // Member: CFullPropSpec::CFullPropSpec, public
  205. //
  206. // Synopsis: Default constructor
  207. //
  208. // Effects: Defines property with null guid and propid 0
  209. //
  210. // History: 22-Jun-93 KyleP Created
  211. //
  212. //--------------------------------------------------------------------------
  213. inline
  214. CFullPropSpec::CFullPropSpec()
  215. {
  216. RtlZeroMemory( &_guidPropSet, sizeof(_guidPropSet) );
  217. _psProperty.ulKind = PRSPEC_PROPID;
  218. _psProperty.propid = 0;
  219. }
  220. //+-------------------------------------------------------------------------
  221. //
  222. // Member: CFullPropSpec::operator=, public
  223. //
  224. // Synopsis: Assignment operator
  225. //
  226. // Arguments: [Property] -- Source property
  227. //
  228. // History: 17-Jul-93 KyleP Created
  229. //
  230. //--------------------------------------------------------------------------
  231. inline
  232. CFullPropSpec & CFullPropSpec::operator=( CFullPropSpec const & Property )
  233. {
  234. //
  235. // Clean up.
  236. //
  237. CFullPropSpec::~CFullPropSpec();
  238. new (this) CFullPropSpec( Property );
  239. return *this;
  240. }
  241. //+-------------------------------------------------------------------------
  242. //
  243. // Class: CColumns
  244. //
  245. // Purpose: C++ wrapper for COLUMNSET
  246. //
  247. // History: 22-Jun-93 KyleP Created
  248. //
  249. //--------------------------------------------------------------------------
  250. class CColumns
  251. {
  252. public:
  253. //
  254. // Constructors
  255. //
  256. CColumns( unsigned size = 0 );
  257. //
  258. // Copy constructors/assignment/clone
  259. //
  260. CColumns( CColumns const & src );
  261. CColumns & operator=( CColumns const & src );
  262. //
  263. // Destructor
  264. //
  265. ~CColumns();
  266. //
  267. // Validity check
  268. //
  269. inline BOOL IsValid() const;
  270. //
  271. // Serialization
  272. //
  273. void Marshall( PSerStream & stm ) const;
  274. CColumns( PDeSerStream & stm );
  275. //
  276. // C/C++ conversion
  277. //
  278. inline COLUMNSET * CastToStruct();
  279. //
  280. // Member variable access
  281. //
  282. void Add( CFullPropSpec const & Property, unsigned pos );
  283. void Remove( unsigned pos );
  284. inline CFullPropSpec const & Get( unsigned pos ) const;
  285. inline unsigned Count() const;
  286. private:
  287. unsigned _cCol;
  288. CFullPropSpec * _aCol;
  289. unsigned _size;
  290. };
  291. //+-------------------------------------------------------------------------
  292. //
  293. // Structure: SortKey
  294. //
  295. // Purpose: wraper for SORTKEY class
  296. //
  297. //--------------------------------------------------------------------------
  298. class CSortKey
  299. {
  300. public:
  301. //
  302. // Constructors
  303. //
  304. inline CSortKey();
  305. CSortKey( CFullPropSpec const & ps, ULONG dwOrder );
  306. CSortKey( CFullPropSpec const & ps, ULONG dwOrder, LCID locale );
  307. //
  308. // Validity check
  309. //
  310. inline BOOL IsValid() const;
  311. //
  312. // Member variable access
  313. //
  314. inline void SetProperty( CFullPropSpec const & ps );
  315. inline CFullPropSpec const & GetProperty() const;
  316. inline ULONG GetOrder() const;
  317. inline LCID GetLocale() const;
  318. inline void SetLocale(LCID locale);
  319. //
  320. // Serialization
  321. //
  322. void Marshall( PSerStream & stm ) const;
  323. CSortKey( PDeSerStream & stm );
  324. private:
  325. CFullPropSpec _property;
  326. ULONG _dwOrder;
  327. LCID _locale;
  328. };
  329. //+-------------------------------------------------------------------------
  330. //
  331. // Class: CSort
  332. //
  333. // Purpose: C++ wrapper for SORTSET
  334. //
  335. // History: 22-Jun-93 KyleP Created
  336. //
  337. //--------------------------------------------------------------------------
  338. class CSort
  339. {
  340. public:
  341. //
  342. // Constructors
  343. //
  344. CSort( unsigned size = 0 );
  345. //
  346. // Copy constructors/assignment/clone
  347. //
  348. CSort( CSort const & src );
  349. CSort & operator=( CSort const & src );
  350. //
  351. // Destructor
  352. //
  353. ~CSort();
  354. //
  355. // Validity check
  356. //
  357. inline BOOL IsValid() const;
  358. //
  359. // C/C++ conversion
  360. //
  361. inline SORTSET * CastToStruct();
  362. //
  363. // Serialization
  364. //
  365. void Marshall( PSerStream & stm ) const;
  366. CSort( PDeSerStream & stm );
  367. //
  368. // Member variable access
  369. //
  370. void Add( CSortKey const &sk, unsigned pos );
  371. void Add( CFullPropSpec const & Property, ULONG dwOrder, unsigned pos );
  372. void Remove( unsigned pos );
  373. inline CSortKey const & Get( unsigned pos ) const;
  374. inline unsigned Count() const;
  375. private:
  376. unsigned _csk;
  377. CSortKey * _ask;
  378. unsigned _size;
  379. };
  380. //+-------------------------------------------------------------------------
  381. //
  382. // Class: CRestriction
  383. //
  384. // Purpose: Base restriction class
  385. //
  386. // History: 31-Dec-93 KyleP Created
  387. //
  388. //--------------------------------------------------------------------------
  389. class CRestriction
  390. {
  391. public:
  392. //
  393. // Constructors
  394. //
  395. inline CRestriction();
  396. inline CRestriction( ULONG RestrictionType, LONG lWeight );
  397. //
  398. // Copy constructors/assigment/clone
  399. //
  400. CRestriction * Clone() const;
  401. //
  402. // Destructor
  403. //
  404. ~CRestriction();
  405. //
  406. // Validity check
  407. //
  408. BOOL IsValid() const;
  409. //
  410. // C/C++ conversion
  411. //
  412. inline RESTRICTION * CastToStruct() const;
  413. //
  414. // Serialization
  415. //
  416. void Marshall( PSerStream & stm ) const;
  417. static CRestriction * UnMarshall( PDeSerStream & stm );
  418. //
  419. // Member variable access
  420. //
  421. inline ULONG Type() const;
  422. inline LONG Weight() const;
  423. inline void SetWeight( LONG lWeight );
  424. inline CNodeRestriction * CastToNode() const;
  425. BOOL IsLeaf() const;
  426. ULONG TreeCount() const;
  427. # ifdef CIEXTMODE
  428. void CiExtDump(void *ciExtSelf);
  429. # endif
  430. protected:
  431. inline void SetType( ULONG RestrictionType );
  432. private:
  433. ULONG _ulType;
  434. LONG _lWeight;
  435. };
  436. //+-------------------------------------------------------------------------
  437. //
  438. // Class: CNodeRestriction
  439. //
  440. // Purpose: Boolean AND/OR/VECTOR restriction
  441. //
  442. // History: 31-Dec-93 KyleP Created
  443. //
  444. //--------------------------------------------------------------------------
  445. class CNodeRestriction : public CRestriction
  446. {
  447. public:
  448. //
  449. // Constructors
  450. //
  451. CNodeRestriction( ULONG NodeType, unsigned cInitAllocated = 2 );
  452. //
  453. // Copy constructors/assignment/clone
  454. //
  455. CNodeRestriction( const CNodeRestriction& nodeRst );
  456. CNodeRestriction * Clone() const;
  457. //
  458. // Destructor
  459. //
  460. ~CNodeRestriction();
  461. //
  462. // Validity check
  463. //
  464. BOOL IsValid() const;
  465. //
  466. // Serialization
  467. //
  468. void Marshall( PSerStream & stm ) const;
  469. CNodeRestriction( ULONG ulType, LONG lWeight, PDeSerStream & stm );
  470. //
  471. // Node manipulation
  472. //
  473. void AddChild( CRestriction * presChild, unsigned & pos );
  474. inline void AddChild( CRestriction * presChild );
  475. CRestriction * RemoveChild( unsigned pos );
  476. //
  477. // Member variable access
  478. //
  479. inline void SetChild( CRestriction * presChild, unsigned pos );
  480. inline CRestriction * GetChild( unsigned pos ) const;
  481. inline unsigned Count() const;
  482. # ifdef CIEXTMODE
  483. void CiExtDump(void *ciExtSelf);
  484. # endif
  485. private:
  486. void Grow();
  487. protected:
  488. ULONG _cNode;
  489. CRestriction ** _paNode;
  490. //
  491. // Members mapped to C structure end here. The following will
  492. // be reserved in the C structure to maintain to C <--> C++
  493. // facade.
  494. //
  495. ULONG _cNodeAllocated;
  496. };
  497. //+-------------------------------------------------------------------------
  498. //
  499. // Class: CNotRestriction
  500. //
  501. // Purpose: Boolean AND/OR/VECTOR restriction
  502. //
  503. // History: 31-Dec-93 KyleP Created
  504. //
  505. //--------------------------------------------------------------------------
  506. class CNotRestriction : public CRestriction
  507. {
  508. public:
  509. //
  510. // Constructors
  511. //
  512. inline CNotRestriction();
  513. inline CNotRestriction( CRestriction * pres );
  514. CNotRestriction( CNotRestriction const & notRst );
  515. CNotRestriction *Clone() const;
  516. //
  517. // Destructor
  518. //
  519. ~CNotRestriction();
  520. //
  521. // Validity check
  522. //
  523. inline BOOL IsValid() const;
  524. //
  525. // Serialization
  526. //
  527. void Marshall( PSerStream & stm ) const;
  528. CNotRestriction( LONG lWeight, PDeSerStream & stm );
  529. //
  530. // Node manipulation
  531. //
  532. inline void SetChild( CRestriction * pres );
  533. inline CRestriction * GetChild() const;
  534. inline CRestriction * RemoveChild();
  535. BOOL HasChild() const { return 0 != _pres; }
  536. # ifdef CIEXTMODE
  537. void CiExtDump(void *ciExtSelf);
  538. # endif
  539. private:
  540. CRestriction * _pres;
  541. };
  542. //+-------------------------------------------------------------------------
  543. //
  544. // Class: CVectorRestriction
  545. //
  546. // Purpose: Extended boolean (vector) restriction
  547. //
  548. // History: 08-Jan-93 KyleP Created
  549. //
  550. //--------------------------------------------------------------------------
  551. class CVectorRestriction : public CNodeRestriction
  552. {
  553. public:
  554. //
  555. // Constructors
  556. //
  557. inline CVectorRestriction( ULONG ulRankMethod,
  558. unsigned cInitAllocated = 128 );
  559. //
  560. // Copy constructors/assignment/clone
  561. //
  562. inline CVectorRestriction( CVectorRestriction const & vecRst );
  563. CVectorRestriction * Clone() const;
  564. //
  565. // Serialization
  566. //
  567. void Marshall( PSerStream & stm ) const;
  568. CVectorRestriction( LONG lWeight, PDeSerStream & stm );
  569. //
  570. // Member variable access
  571. //
  572. inline void SetRankMethod( ULONG ulRankMethod );
  573. inline ULONG RankMethod() const;
  574. # ifdef CIEXTMODE
  575. void CiExtDump(void *ciExtSelf);
  576. # endif
  577. private:
  578. ULONG _ulRankMethod;
  579. };
  580. //+-------------------------------------------------------------------------
  581. //
  582. // Class: CContentRestriction
  583. //
  584. // Purpose: Scope restriction
  585. //
  586. // History: 07-Jan-93 KyleP Created
  587. //
  588. //--------------------------------------------------------------------------
  589. class CContentRestriction : public CRestriction
  590. {
  591. public:
  592. //
  593. // Constructors
  594. //
  595. CContentRestriction( WCHAR const * pwcsPhrase,
  596. CFullPropSpec const & Property,
  597. ULONG ulGenerateMethod = 0,
  598. LCID lcid = GetSystemDefaultLCID() );
  599. CContentRestriction( CContentRestriction const & contentRst );
  600. //
  601. // Copy constructors/assignment/clone
  602. //
  603. CContentRestriction * Clone() const;
  604. //
  605. // Destructor
  606. //
  607. ~CContentRestriction();
  608. //
  609. // Validity check
  610. //
  611. inline BOOL IsValid() const;
  612. //
  613. // Serialization
  614. //
  615. void Marshall( PSerStream & stm ) const;
  616. CContentRestriction( LONG lWeight, PDeSerStream & stm );
  617. //
  618. // Member variable access
  619. //
  620. void SetPhrase( WCHAR const * pwcsPhrase );
  621. inline WCHAR const * GetPhrase() const;
  622. inline void SetProperty( CFullPropSpec const & Property );
  623. inline CFullPropSpec const & GetProperty() const;
  624. LCID GetLocale() const { return _lcid; }
  625. inline void SetGenerateMethod( ULONG ulGenerateMethod );
  626. inline ULONG GenerateMethod() const;
  627. # ifdef CIEXTMODE
  628. void CiExtDump(void *ciExtSelf);
  629. # endif
  630. private:
  631. CFullPropSpec _Property; // Property Name
  632. WCHAR * _pwcsPhrase; // content
  633. LCID _lcid;
  634. ULONG _ulGenerateMethod; // Generate method.
  635. };
  636. //+-------------------------------------------------------------------------
  637. //
  638. // Class: CComplexContentRestriction
  639. //
  640. // Purpose: Supports scaffolding query language
  641. //
  642. // History: 08-Jan-93 KyleP Created
  643. //
  644. //--------------------------------------------------------------------------
  645. class CComplexContentRestriction : public CRestriction
  646. {
  647. public:
  648. //
  649. // Constructors
  650. //
  651. CComplexContentRestriction( WCHAR * pwcsExpression,
  652. LCID lcid = GetSystemDefaultLCID() );
  653. CComplexContentRestriction( const CComplexContentRestriction& compRst );
  654. //
  655. // Copy constructors/assignment/clone
  656. //
  657. CComplexContentRestriction * Clone() const;
  658. //
  659. // Destructors
  660. //
  661. ~CComplexContentRestriction();
  662. //
  663. // Validity check
  664. //
  665. BOOL IsValid() const;
  666. //
  667. // Serialization
  668. //
  669. void Marshall( PSerStream & stm ) const;
  670. CComplexContentRestriction( LONG lWeight, PDeSerStream & stm );
  671. //
  672. // Member variable access
  673. //
  674. void SetExpression( WCHAR * pwcsExpression );
  675. inline WCHAR * GetExpression();
  676. LCID GetLocale() const { return _lcid; }
  677. # ifdef CIEXTMODE
  678. void CiExtDump(void *ciExtSelf);
  679. # endif
  680. private:
  681. WCHAR * _pwcsExpression;
  682. LCID _lcid;
  683. };
  684. //+-------------------------------------------------------------------------
  685. //
  686. // Class: CNatLanguageRestriction
  687. //
  688. // Purpose: Supports natural language queries
  689. //
  690. // History: 18-Jan-95 SitaramR Created
  691. //
  692. //--------------------------------------------------------------------------
  693. class CNatLanguageRestriction : public CRestriction
  694. {
  695. public:
  696. //
  697. // Constructors
  698. //
  699. CNatLanguageRestriction( WCHAR const * pwcsPhrase,
  700. CFullPropSpec const & Property,
  701. LCID lcid = GetSystemDefaultLCID() );
  702. //
  703. // Copy constructors/assignment/clone
  704. //
  705. CNatLanguageRestriction * Clone() const;
  706. //
  707. // Destructors
  708. //
  709. ~CNatLanguageRestriction();
  710. //
  711. // Validity check
  712. //
  713. inline BOOL IsValid() const;
  714. //
  715. // Serialization
  716. //
  717. void Marshall( PSerStream & stm ) const;
  718. CNatLanguageRestriction( LONG lWeight, PDeSerStream & stm );
  719. //
  720. // Member variable access
  721. //
  722. void SetPhrase( WCHAR const * pwcsPhrase );
  723. inline WCHAR const * GetPhrase() const;
  724. inline void SetProperty( CFullPropSpec const & Property );
  725. inline CFullPropSpec const & GetProperty() const;
  726. LCID GetLocale() const { return _lcid; }
  727. # ifdef CIEXTMODE
  728. void CiExtDump(void *ciExtSelf);
  729. # endif
  730. private:
  731. CFullPropSpec _Property; // Property Name
  732. WCHAR * _pwcsPhrase; // content
  733. LCID _lcid;
  734. };
  735. //+-------------------------------------------------------------------------
  736. //
  737. // Class: CPropertyRestriction
  738. //
  739. // Purpose: Property <relop> constant restriction
  740. //
  741. // History: 08-Jan-93 KyleP Created
  742. // 08-Nov-93 DwightKr Added new SetValue() methods
  743. //
  744. //--------------------------------------------------------------------------
  745. class CPropertyRestriction : public CRestriction
  746. {
  747. public:
  748. //
  749. // Constructors
  750. //
  751. CPropertyRestriction();
  752. CPropertyRestriction( ULONG relop,
  753. CFullPropSpec const & Property,
  754. CStorageVariant const & prval );
  755. //
  756. // Copy constructors/assignment/clone
  757. //
  758. CPropertyRestriction * Clone() const;
  759. //
  760. // Destructors
  761. //
  762. ~CPropertyRestriction();
  763. //
  764. // Validity check
  765. //
  766. inline BOOL IsValid() const;
  767. //
  768. // Serialization
  769. //
  770. void Marshall( PSerStream & stm ) const;
  771. CPropertyRestriction( LONG lWeight, PDeSerStream & stm );
  772. //
  773. // Member variable access
  774. //
  775. inline void SetRelation( ULONG relop );
  776. inline ULONG Relation();
  777. inline void SetProperty( CFullPropSpec const & Property );
  778. inline CFullPropSpec const & GetProperty() const;
  779. inline void SetValue( double dValue );
  780. inline void SetUI4( ULONG ulValue );
  781. inline void SetValue( ULONG ulValue );
  782. inline void SetValue( LONG lValue );
  783. inline void SetValue( LARGE_INTEGER llValue );
  784. inline void SetValue( FILETIME ftValue );
  785. inline void SetValue( CY CyValue );
  786. inline void SetValue( float fValue );
  787. inline void SetValue( SHORT sValue );
  788. inline void SetValue( const CStorageVariant &prval );
  789. inline void SetDate ( DATE dValue );
  790. inline void SetBOOL( BOOL fValue );
  791. void SetValue( BLOB & bValue );
  792. void SetValue( WCHAR * pwcsValue );
  793. void SetValue( GUID * pguidValue);
  794. inline CStorageVariant const & Value();
  795. # ifdef CIEXTMODE
  796. void CiExtDump(void *ciExtSelf);
  797. # endif
  798. private:
  799. void _CleanValue();
  800. ULONG _relop; // Relation
  801. CFullPropSpec _Property; // Property Name
  802. CStorageVariant _prval; // Constant value
  803. };
  804. //
  805. // Inline methods for CFullPropSpec
  806. //
  807. inline void * CFullPropSpec::operator new( size_t size )
  808. {
  809. void * p = CoTaskMemAlloc( size );
  810. return( p );
  811. }
  812. inline void * CFullPropSpec::operator new( size_t size, void * p )
  813. {
  814. return( p );
  815. }
  816. inline void CFullPropSpec::operator delete( void * p )
  817. {
  818. if ( p )
  819. CoTaskMemFree( p );
  820. }
  821. #if _MSC_VER >= 1200
  822. inline void CFullPropSpec::operator delete( void * p, void * pp )
  823. {
  824. return;
  825. }
  826. #endif
  827. inline BOOL CFullPropSpec::IsValid() const
  828. {
  829. return ( ( _psProperty.ulKind == PRSPEC_PROPID ) ||
  830. ( ( _psProperty.ulKind == PRSPEC_LPWSTR ) &&
  831. ( 0 != _psProperty.lpwstr ) ) );
  832. }
  833. inline void CFullPropSpec::SetPropSet( GUID const & guidPropSet )
  834. {
  835. _guidPropSet = guidPropSet;
  836. }
  837. inline GUID const & CFullPropSpec::GetPropSet() const
  838. {
  839. return( _guidPropSet );
  840. }
  841. inline PROPSPEC CFullPropSpec::GetPropSpec() const
  842. {
  843. return( _psProperty );
  844. }
  845. inline WCHAR const * CFullPropSpec::GetPropertyName() const
  846. {
  847. return( _psProperty.lpwstr );
  848. }
  849. inline PROPID CFullPropSpec::GetPropertyPropid() const
  850. {
  851. return( _psProperty.propid );
  852. }
  853. inline BOOL CFullPropSpec::IsPropertyName() const
  854. {
  855. return( _psProperty.ulKind == PRSPEC_LPWSTR );
  856. }
  857. inline BOOL CFullPropSpec::IsPropertyPropid() const
  858. {
  859. return( _psProperty.ulKind == PRSPEC_PROPID );
  860. }
  861. inline BOOL CColumns::IsValid() const
  862. {
  863. return ( 0 != _aCol );
  864. }
  865. inline CFullPropSpec const & CColumns::Get( unsigned pos ) const
  866. {
  867. if ( pos < _cCol )
  868. return( _aCol[pos] );
  869. else
  870. return( *(CFullPropSpec *)0 );
  871. }
  872. //
  873. // Inline methods for CColumns
  874. //
  875. inline unsigned CColumns::Count() const
  876. {
  877. return( _cCol );
  878. }
  879. inline COLUMNSET * CColumns::CastToStruct()
  880. {
  881. return( (COLUMNSET *)this );
  882. }
  883. //
  884. // Inline methods for CSortKey
  885. //
  886. inline CSortKey::CSortKey()
  887. {
  888. }
  889. inline BOOL CSortKey::IsValid() const
  890. {
  891. return _property.IsValid();
  892. }
  893. inline void CSortKey::SetProperty( CFullPropSpec const & ps )
  894. {
  895. _property = ps;
  896. }
  897. inline void CSortKey::SetLocale( LCID locale )
  898. {
  899. _locale = locale;
  900. }
  901. inline CFullPropSpec const & CSortKey::GetProperty() const
  902. {
  903. return( _property );
  904. }
  905. inline LCID CSortKey::GetLocale() const
  906. {
  907. return( _locale );
  908. }
  909. inline ULONG CSortKey::GetOrder() const
  910. {
  911. return( _dwOrder );
  912. }
  913. //
  914. // Inline methods of CSort
  915. //
  916. inline BOOL CSort::IsValid() const
  917. {
  918. return ( 0 != _ask );
  919. }
  920. inline SORTSET * CSort::CastToStruct()
  921. {
  922. return( (SORTSET *)this );
  923. }
  924. inline CSortKey const & CSort::Get( unsigned pos ) const
  925. {
  926. if ( pos < _csk )
  927. {
  928. return( _ask[pos] );
  929. }
  930. else
  931. {
  932. return( *(CSortKey *)0 );
  933. }
  934. }
  935. inline unsigned
  936. CSort::Count() const
  937. {
  938. return( _csk );
  939. }
  940. //
  941. // Inline methods of CRestriction
  942. //
  943. inline CRestriction::CRestriction()
  944. : _ulType( RTNone ),
  945. _lWeight( MAX_QUERY_RANK )
  946. {
  947. }
  948. inline CRestriction::CRestriction( ULONG RestrictionType, LONG lWeight )
  949. : _ulType( RestrictionType ),
  950. _lWeight( lWeight )
  951. {
  952. }
  953. inline RESTRICTION * CRestriction::CastToStruct() const
  954. {
  955. //
  956. // It would be nice to assert valid _ulType here, but there is
  957. // no published assert mechanism for external use.
  958. //
  959. return ( (RESTRICTION *)this );
  960. }
  961. inline FULLPROPSPEC * CFullPropSpec::CastToStruct()
  962. {
  963. return((FULLPROPSPEC *) this);
  964. }
  965. inline FULLPROPSPEC const * CFullPropSpec::CastToStruct() const
  966. {
  967. return((FULLPROPSPEC const *) this);
  968. }
  969. inline ULONG CRestriction::Type() const
  970. {
  971. return ( _ulType );
  972. }
  973. inline LONG CRestriction::Weight() const
  974. {
  975. return ( _lWeight );
  976. }
  977. inline void CRestriction::SetWeight( LONG lWeight )
  978. {
  979. _lWeight = lWeight;
  980. }
  981. inline void CRestriction::SetType( ULONG RestrictionType )
  982. {
  983. _ulType = RestrictionType;
  984. }
  985. //
  986. // Inline methods of CNodeRestriction
  987. //
  988. inline void CNodeRestriction::AddChild( CRestriction * prst )
  989. {
  990. unsigned pos;
  991. AddChild( prst, pos );
  992. }
  993. inline unsigned CNodeRestriction::Count() const
  994. {
  995. return _cNode;
  996. }
  997. inline CNodeRestriction * CRestriction::CastToNode() const
  998. {
  999. //
  1000. // It would be nice to assert node type here, but there is
  1001. // no published assert mechanism for external use.
  1002. //
  1003. return ( (CNodeRestriction *)this );
  1004. }
  1005. inline void CNodeRestriction::SetChild( CRestriction * presChild,
  1006. unsigned pos )
  1007. {
  1008. if ( pos < _cNode )
  1009. _paNode[pos] = presChild;
  1010. }
  1011. inline CRestriction * CNodeRestriction::GetChild( unsigned pos ) const
  1012. {
  1013. if ( pos < _cNode )
  1014. return( _paNode[pos] );
  1015. else
  1016. return( 0 );
  1017. }
  1018. //
  1019. // Inline methods of CNotRestriction
  1020. //
  1021. inline CNotRestriction::CNotRestriction()
  1022. : CRestriction( RTNot, MAX_QUERY_RANK ),
  1023. _pres(0)
  1024. {
  1025. }
  1026. inline CNotRestriction::CNotRestriction( CRestriction * pres )
  1027. : CRestriction( RTNot, MAX_QUERY_RANK ),
  1028. _pres( pres )
  1029. {
  1030. }
  1031. inline BOOL CNotRestriction::IsValid() const
  1032. {
  1033. return ( 0 != _pres && _pres->IsValid() );
  1034. }
  1035. inline void CNotRestriction::SetChild( CRestriction * pres )
  1036. {
  1037. delete _pres;
  1038. _pres = pres;
  1039. }
  1040. inline CRestriction * CNotRestriction::GetChild() const
  1041. {
  1042. return( _pres );
  1043. }
  1044. inline CRestriction * CNotRestriction::RemoveChild()
  1045. {
  1046. CRestriction *pRst = _pres;
  1047. _pres = 0;
  1048. return pRst;
  1049. }
  1050. //
  1051. // Inline methods of CVectorRestriction
  1052. //
  1053. inline CVectorRestriction::CVectorRestriction( ULONG ulRankMethod,
  1054. unsigned cInitAllocated )
  1055. : CNodeRestriction( RTVector, cInitAllocated )
  1056. {
  1057. SetRankMethod( ulRankMethod );
  1058. }
  1059. inline CVectorRestriction::CVectorRestriction( CVectorRestriction const & vecRst )
  1060. : CNodeRestriction( vecRst ),
  1061. _ulRankMethod( vecRst.RankMethod() )
  1062. {
  1063. }
  1064. inline void CVectorRestriction::SetRankMethod( ULONG ulRankMethod )
  1065. {
  1066. if ( ulRankMethod <= VECTOR_RANK_JACCARD )
  1067. _ulRankMethod = ulRankMethod;
  1068. else
  1069. _ulRankMethod = VECTOR_RANK_JACCARD;
  1070. }
  1071. inline ULONG CVectorRestriction::RankMethod() const
  1072. {
  1073. return ( _ulRankMethod );
  1074. }
  1075. //
  1076. // Inline methods of CContentRestriction
  1077. //
  1078. inline BOOL CContentRestriction::IsValid() const
  1079. {
  1080. return ( _Property.IsValid() && 0 != _pwcsPhrase );
  1081. }
  1082. inline WCHAR const * CContentRestriction::GetPhrase() const
  1083. {
  1084. return( _pwcsPhrase );
  1085. }
  1086. inline void CContentRestriction::SetProperty( CFullPropSpec const & Property )
  1087. {
  1088. _Property = Property;
  1089. }
  1090. inline CFullPropSpec const & CContentRestriction::GetProperty() const
  1091. {
  1092. return( _Property );
  1093. }
  1094. inline void CContentRestriction::SetGenerateMethod( ULONG ulGenerateMethod )
  1095. {
  1096. _ulGenerateMethod = ulGenerateMethod;
  1097. }
  1098. inline ULONG CContentRestriction::GenerateMethod() const
  1099. {
  1100. return( _ulGenerateMethod );
  1101. }
  1102. //
  1103. // Inline methods of CComplexContentRestriction
  1104. //
  1105. inline BOOL CComplexContentRestriction::IsValid() const
  1106. {
  1107. return ( 0 != _pwcsExpression );
  1108. }
  1109. inline WCHAR * CComplexContentRestriction::GetExpression()
  1110. {
  1111. return( _pwcsExpression );
  1112. }
  1113. //
  1114. // Inline methods of CNatLanguageRestriction
  1115. //
  1116. inline BOOL CNatLanguageRestriction::IsValid() const
  1117. {
  1118. return ( _Property.IsValid() && 0 != _pwcsPhrase );
  1119. }
  1120. inline WCHAR const * CNatLanguageRestriction::GetPhrase() const
  1121. {
  1122. return( _pwcsPhrase );
  1123. }
  1124. inline void CNatLanguageRestriction::SetProperty( CFullPropSpec const & Property )
  1125. {
  1126. _Property = Property;
  1127. }
  1128. inline CFullPropSpec const & CNatLanguageRestriction::GetProperty() const
  1129. {
  1130. return( _Property );
  1131. }
  1132. //
  1133. // Inline methods of CPropertyRestriction
  1134. //
  1135. inline BOOL CPropertyRestriction::IsValid() const
  1136. {
  1137. return ( _Property.IsValid() && _prval.IsValid() );
  1138. }
  1139. inline void CPropertyRestriction::SetRelation( ULONG relop )
  1140. {
  1141. _relop = relop;
  1142. }
  1143. inline ULONG CPropertyRestriction::Relation()
  1144. {
  1145. return( _relop );
  1146. }
  1147. inline void CPropertyRestriction::SetProperty( CFullPropSpec const & Property )
  1148. {
  1149. _Property = Property;
  1150. }
  1151. inline CFullPropSpec const & CPropertyRestriction::GetProperty() const
  1152. {
  1153. return( _Property );
  1154. }
  1155. inline void CPropertyRestriction::SetValue( double dValue )
  1156. {
  1157. _prval = dValue;
  1158. }
  1159. inline void CPropertyRestriction::SetValue( ULONG ulValue )
  1160. {
  1161. _prval.SetUI4( ulValue );
  1162. }
  1163. inline void CPropertyRestriction::SetUI4( ULONG ulValue )
  1164. {
  1165. _prval.SetUI4( ulValue );
  1166. }
  1167. inline void CPropertyRestriction::SetValue( LONG lValue )
  1168. {
  1169. _prval = lValue;
  1170. }
  1171. inline void CPropertyRestriction::SetValue( LARGE_INTEGER llValue )
  1172. {
  1173. _prval = llValue;
  1174. }
  1175. inline void CPropertyRestriction::SetValue( FILETIME ftValue )
  1176. {
  1177. _prval = ftValue;
  1178. }
  1179. inline void CPropertyRestriction::SetValue( CY cyValue )
  1180. {
  1181. _prval = cyValue;
  1182. }
  1183. inline void CPropertyRestriction::SetValue( float fValue )
  1184. {
  1185. _prval = fValue;
  1186. }
  1187. inline void CPropertyRestriction::SetValue( SHORT sValue )
  1188. {
  1189. _prval = sValue;
  1190. }
  1191. inline void CPropertyRestriction::SetValue( const CStorageVariant &prval )
  1192. {
  1193. _prval = prval;
  1194. }
  1195. inline void CPropertyRestriction::SetBOOL( BOOL fValue )
  1196. {
  1197. _prval.SetBOOL( (SHORT)fValue );
  1198. }
  1199. inline void CPropertyRestriction::SetDate( DATE dValue )
  1200. {
  1201. _prval.SetDATE( dValue );
  1202. }
  1203. inline CStorageVariant const & CPropertyRestriction::Value()
  1204. {
  1205. return( _prval );
  1206. }
  1207. #endif // __RESTRICT_HXX__