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.

4638 lines
94 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1999.
  5. //
  6. // File: dbcmdbas.hxx
  7. //
  8. // Contents: Helper classes for dealing with DBCOMMANDTREE and DBID
  9. // structures.
  10. //
  11. // Classes: CDbCmdTreeNode
  12. // CDbColumnNode
  13. // CDbScalarValue
  14. // CDbTableId
  15. // CDbSelectNode
  16. // CDbListAnchor
  17. // CDbProjectListAnchor
  18. // CDbProjectListElement
  19. // CDbProjectNode
  20. // CDbSortListAnchor
  21. // CDbSortListElement
  22. // CDbSortNode
  23. // CDbRestriction
  24. // CDbNodeRestriction
  25. // CDbNotRestriction
  26. // CDbPropBaseRestriction
  27. // CDbPropertyRestriction
  28. // CDbVectorRestriction
  29. // CDbContentBaseRestriction
  30. // CDbNatLangRestriction
  31. // CDbContentRestriction
  32. // CDbTopNode
  33. // CDbColId
  34. // CDbDataType
  35. // CDbColDesc
  36. // CDbGuidName
  37. // CDbGuidPropid
  38. // CDbText
  39. // CDbContent
  40. // CDbSortInfo
  41. // CDbGroupInfo
  42. // CDbColumns
  43. // CDbSortSet
  44. // CDbPropSet
  45. // CDbProp
  46. // CDbPropIDSet
  47. //
  48. // Functions: CastToStorageVariant
  49. //
  50. // History: 6-06-95 srikants Created
  51. //
  52. //----------------------------------------------------------------------------
  53. #ifndef __DBCMDTRE_HXX__
  54. #define __DBCMDTRE_HXX__
  55. #include <oledb.h>
  56. #include <cmdtree.h>
  57. #include <oledbdep.h> // NOTE: only for DBGUID_LIKE_OFS
  58. #include <sstream.hxx>
  59. #include <stgvar.hxx>
  60. #include <pshpack2.h> // oledb.h uses 2-byte packing
  61. #define DBOP_firstrows 258
  62. //+---------------------------------------------------------------------------
  63. //
  64. // Function: CastToStorageVariant
  65. //
  66. // Synopsis: To treat a variant as a CStorageVariant. Because CStorageVariant
  67. // derives from PROPVARIANT in a "protected" fashion, we cannot
  68. // directly typecast a PROPVARIANT * to a CStorageVariant *
  69. //
  70. // Arguments: [varnt] - The variant that must be type casted.
  71. //
  72. // Returns: A pointer to varnt as a CStorageVariant.
  73. //
  74. // History: 6-06-95 srikants Created
  75. //
  76. // Notes: There are two overloaded implementations, one to convert
  77. // a reference to const to a pointer to const.
  78. //
  79. //----------------------------------------------------------------------------
  80. inline
  81. CStorageVariant * CastToStorageVariant( VARIANT & varnt )
  82. {
  83. return (CStorageVariant *) ((void *) &varnt);
  84. }
  85. inline
  86. CStorageVariant const * CastToStorageVariant( VARIANT const & varnt )
  87. {
  88. return (CStorageVariant *) ((void *) &varnt);
  89. }
  90. //+---------------------------------------------------------------------------
  91. //
  92. // Class: CDbColId
  93. //
  94. // Purpose: Wrapper for DBID
  95. //
  96. // Interface: Marshall --
  97. // UnMarshall --
  98. // Get --
  99. //
  100. // History: 6-21-95 srikants Created
  101. //
  102. // Notes: This class does not completely handle the simple name
  103. // and pointer to guid forms of DBID.
  104. //
  105. //----------------------------------------------------------------------------
  106. class CDbColId : public DBID
  107. {
  108. public:
  109. CDbColId();
  110. CDbColId( GUID const & guidPropSet, PROPID pidProperty )
  111. {
  112. eKind = DBKIND_GUID_PROPID;
  113. uGuid.guid = guidPropSet;
  114. uName.ulPropid = pidProperty;
  115. }
  116. CDbColId( GUID const & guidPropSet, WCHAR const * wcsProperty );
  117. CDbColId( DBID const & propSpec );
  118. CDbColId( CDbColId const & propSpec );
  119. CDbColId( PROPID pidProperty )
  120. {
  121. eKind = DBKIND_PROPID;
  122. uName.ulPropid = pidProperty;
  123. }
  124. CDbColId( WCHAR const * wcsProperty )
  125. {
  126. eKind = DBKIND_NAME;
  127. uName.pwszName = 0;
  128. SetProperty( wcsProperty );
  129. }
  130. ~CDbColId()
  131. {
  132. Cleanup();
  133. }
  134. void Marshall( PSerStream & stm ) const;
  135. BOOL UnMarshall( PDeSerStream & stm );
  136. DBID & Get() const { return (DBID &)*this; }
  137. BOOL Copy( DBID const & rhs );
  138. CDbColId & operator=( CDbColId const & Property );
  139. //
  140. // Comparators
  141. //
  142. int operator==( CDbColId const & prop ) const;
  143. int operator!=( CDbColId const & prop ) const
  144. {
  145. return !operator==(prop);
  146. }
  147. //
  148. // Member variable access
  149. //
  150. void SetPropSet( GUID const & guidPropSet )
  151. {
  152. if ( DBKIND_GUID_PROPID == eKind ||
  153. DBKIND_GUID_NAME == eKind )
  154. {
  155. uGuid.guid = guidPropSet;
  156. return;
  157. }
  158. // upgrading from propid to guid propid
  159. if ( DBKIND_PROPID == eKind )
  160. {
  161. eKind = DBKIND_GUID_PROPID;
  162. uGuid.guid = guidPropSet;
  163. return;
  164. }
  165. // upgrading from name to guid name
  166. if ( DBKIND_NAME == eKind )
  167. {
  168. eKind = DBKIND_GUID_NAME;
  169. uGuid.guid = guidPropSet;
  170. return;
  171. }
  172. if ( DBKIND_PGUID_NAME == eKind ||
  173. DBKIND_PGUID_PROPID == eKind )
  174. *uGuid.pguid = guidPropSet;
  175. }
  176. GUID const & GetPropSet() const
  177. {
  178. if ( DBKIND_GUID_PROPID == eKind ||
  179. DBKIND_GUID_NAME == eKind )
  180. return uGuid.guid;
  181. if ( DBKIND_PGUID_NAME == eKind ||
  182. DBKIND_PGUID_PROPID == eKind )
  183. return *uGuid.pguid;
  184. return uGuid.guid;
  185. }
  186. void SetProperty( PROPID pidProperty )
  187. {
  188. Cleanup();
  189. eKind = DBKIND_GUID_PROPID;
  190. uName.ulPropid = pidProperty;
  191. }
  192. BOOL SetProperty( WCHAR const * wcsProperty );
  193. WCHAR const * GetPropertyName() const
  194. {
  195. return uName.pwszName;
  196. }
  197. WCHAR * GetPropertyName()
  198. {
  199. return uName.pwszName;
  200. }
  201. PROPID GetPropertyPropid() const
  202. {
  203. return uName.ulPropid;
  204. }
  205. PROPSPEC GetPropSpec() const
  206. {
  207. return( *(PROPSPEC *)(void *)&eKind );
  208. }
  209. BOOL IsPropertyName() const
  210. {
  211. return DBKIND_GUID_NAME == eKind ||
  212. DBKIND_PGUID_NAME == eKind ||
  213. DBKIND_NAME == eKind;
  214. }
  215. BOOL IsPropertyPropid() const
  216. {
  217. return DBKIND_GUID_PROPID == eKind ||
  218. DBKIND_PROPID == eKind ||
  219. DBKIND_PGUID_PROPID == eKind;
  220. }
  221. BOOL IsPropSetPresent() const
  222. {
  223. return (DBKIND_PROPID != eKind) && (DBKIND_NAME != eKind);
  224. }
  225. BOOL IsValid() const
  226. {
  227. // Most common cases first
  228. if ( DBKIND_GUID_PROPID == eKind )
  229. return TRUE;
  230. if ( DBKIND_GUID_NAME == eKind ||
  231. DBKIND_NAME == eKind )
  232. return 0 != uName.pwszName;
  233. if ( DBKIND_PROPID == eKind ||
  234. DBKIND_GUID == eKind )
  235. return TRUE;
  236. if ( DBKIND_PGUID_PROPID == eKind )
  237. return 0 != uGuid.pguid;
  238. if ( DBKIND_PGUID_NAME == eKind )
  239. return 0 != uGuid.pguid && 0 != uName.pwszName;
  240. return FALSE;
  241. }
  242. DBID * CastToStruct()
  243. {
  244. return (DBID *) this;
  245. }
  246. DBID const * CastToStruct() const
  247. {
  248. return (DBID const *) this;
  249. }
  250. void Cleanup();
  251. //
  252. // Memory allocation
  253. //
  254. void * operator new( size_t size );
  255. inline void * operator new( size_t size, void * p );
  256. void operator delete( void * p );
  257. private:
  258. BOOL _IsPGuidUsed() const
  259. {
  260. return DBKIND_PGUID_NAME == eKind || DBKIND_PGUID_PROPID == eKind;
  261. }
  262. BOOL _IsValidKind() const
  263. {
  264. return eKind <= DBKIND_GUID;
  265. }
  266. };
  267. //+---------------------------------------------------------------------------
  268. //
  269. // Method: CDbColId::operator new
  270. //
  271. // Synopsis: Command tree node allocation via IMalloc::Alloc
  272. //
  273. // Arguments: [size] -
  274. //
  275. // History: 6-06-95 srikants Created
  276. //
  277. // Notes:
  278. //
  279. //----------------------------------------------------------------------------
  280. inline void * CDbColId::operator new( size_t size )
  281. {
  282. return CoTaskMemAlloc( size );
  283. }
  284. //+---------------------------------------------------------------------------
  285. //
  286. // Method: CDbColId::operator new
  287. //
  288. // Synopsis: null allocator
  289. //
  290. // Arguments: [size] -
  291. // [p] -
  292. //
  293. // History: 6-06-95 srikants Created
  294. //
  295. // Notes:
  296. //
  297. //----------------------------------------------------------------------------
  298. inline void * CDbColId::operator new( size_t size, void * p )
  299. {
  300. return( p );
  301. }
  302. //+---------------------------------------------------------------------------
  303. //
  304. // Method: CDbColId::operator delete
  305. //
  306. // Synopsis: CDbColId deallocation via IMalloc::Free
  307. //
  308. // Arguments: [p] -
  309. //
  310. // History: 6-06-95 srikants Created
  311. //
  312. // Notes:
  313. //
  314. //----------------------------------------------------------------------------
  315. inline void CDbColId::operator delete( void * p )
  316. {
  317. CoTaskMemFree( p );
  318. }
  319. #if 0
  320. class CXXXX : public XXXX
  321. {
  322. public:
  323. ~CXXX();
  324. //
  325. // Memory allocation
  326. //
  327. void * operator new( size_t size )
  328. {
  329. void * p = CoTaskMemAlloc( size );
  330. return( p );
  331. }
  332. inline void * operator new( size_t size, void * p )
  333. {
  334. return( p );
  335. }
  336. void operator delete( void * p )
  337. {
  338. if ( p )
  339. CoTaskMemFree( p );
  340. }
  341. void Marshall( PSerStream & stm ) const;
  342. BOOL UnMarshall( PDeSerStream & stm );
  343. BOOL IsValid() const
  344. {
  345. return TRUE;
  346. }
  347. private:
  348. };
  349. #endif // 0
  350. //+---------------------------------------------------------------------------
  351. //
  352. // Class: CDbCmdTreeNode
  353. //
  354. // Purpose: Basic DBCOMMANDTREE node
  355. //
  356. // History: 6-06-95 srikants Created
  357. //
  358. // Notes:
  359. //
  360. //----------------------------------------------------------------------------
  361. class CDbCmdTreeNode : protected DBCOMMANDTREE
  362. {
  363. // Needed to access AppendChild. Consider having a base class
  364. // for projectlist element nodes
  365. friend class CDbListAnchor;
  366. public:
  367. //
  368. // Constructor and Destructor
  369. //
  370. CDbCmdTreeNode( DBCOMMANDOP opVal = DBOP_DEFAULT,
  371. WORD eType = DBVALUEKIND_EMPTY )
  372. {
  373. RtlZeroMemory( this, sizeof(CDbCmdTreeNode) );
  374. op = opVal;
  375. wKind = eType;
  376. //
  377. // pctFirstChild = pctNextSibling = 0;
  378. // This assignment is not needed because we have already initialized
  379. // the whole structure with 0s.
  380. //
  381. }
  382. ~CDbCmdTreeNode();
  383. DBCOMMANDOP GetCommandType() const { return op; }
  384. DBVALUEKIND GetValueType() const { return wKind; }
  385. CDbCmdTreeNode * GetFirstChild() const
  386. {
  387. return (CDbCmdTreeNode *) pctFirstChild;
  388. }
  389. CDbCmdTreeNode * GetNextSibling() const
  390. {
  391. return (CDbCmdTreeNode *) pctNextSibling;
  392. }
  393. void SetError( SCODE scErr )
  394. {
  395. hrError = scErr;
  396. }
  397. SCODE GetError( ) const { return hrError; }
  398. void FreeChildren()
  399. {
  400. if ( 0 != pctFirstChild )
  401. {
  402. delete pctFirstChild;
  403. pctFirstChild = 0;
  404. }
  405. }
  406. CDbCmdTreeNode * AcquireChildren()
  407. {
  408. CDbCmdTreeNode * pNode = GetFirstChild();
  409. pctFirstChild = 0;
  410. return pNode;
  411. }
  412. void SetChildren( CDbCmdTreeNode* pListElement );
  413. DBCOMMANDTREE * CastToStruct() const
  414. {
  415. return (DBCOMMANDTREE *)this;
  416. }
  417. static CDbCmdTreeNode * CastFromStruct( DBCOMMANDTREE * pNode )
  418. {
  419. return (CDbCmdTreeNode *) (pNode);
  420. }
  421. static CDbCmdTreeNode const * CastFromStruct( DBCOMMANDTREE const * pNode )
  422. {
  423. return (CDbCmdTreeNode const *) (pNode);
  424. }
  425. BOOL IsScalarNode() const
  426. {
  427. return DBOP_scalar_constant == op;
  428. }
  429. BOOL IsColumnName() const
  430. {
  431. return DBOP_column_name == op;
  432. }
  433. BOOL IsOpValid( DBCOMMANDOP opVal ) const
  434. {
  435. return op == opVal;
  436. }
  437. BOOL IsSelectNode() const
  438. {
  439. return DBOP_select == op;
  440. }
  441. BOOL IsProjectNode() const
  442. {
  443. return DBOP_project == op;
  444. }
  445. BOOL IsSortNode() const
  446. {
  447. return DBOP_sort == op;
  448. }
  449. BOOL IsListAnchor() const
  450. {
  451. return DBOP_project_list_anchor == op ||
  452. DBOP_sort_list_anchor == op;
  453. }
  454. //
  455. // Cloning the tree
  456. //
  457. CDbCmdTreeNode * Clone( BOOL fCopyErrors = FALSE ) const;
  458. void TransferNode( CDbCmdTreeNode *pNode );
  459. //
  460. // Serialization and DeSerialization
  461. //
  462. void Marshall( PSerStream & stm ) const;
  463. BOOL UnMarshall( PDeSerStream & stm );
  464. static CDbCmdTreeNode * UnMarshallTree( PDeSerStream & stm );
  465. static void PutWString( PSerStream & stm, const WCHAR * pwszStr );
  466. static WCHAR * GetWString( PDeSerStream & stm, BOOL & fSuccess, BOOL fBstr = FALSE );
  467. static WCHAR * AllocAndCopyWString( const WCHAR * pSrc );
  468. //
  469. // Memory allocation
  470. //
  471. void * operator new( size_t size );
  472. inline void * operator new( size_t size, void * p );
  473. void operator delete( void * p );
  474. //
  475. // A NULL guid variable.
  476. //
  477. static const GUID guidNull; // NULL guid
  478. void SetWeight(LONG lWeight);
  479. LONG GetWeight() const;
  480. protected:
  481. void CleanupDataValue();
  482. void CleanupValue()
  483. {
  484. if ( DBVALUEKIND_EMPTY != wKind )
  485. CleanupDataValue();
  486. }
  487. //
  488. // Setting protected members
  489. //
  490. void SetCommandType( DBCOMMANDOP opVal )
  491. {
  492. op = opVal;
  493. }
  494. void SetValueType( WORD wKindVal )
  495. {
  496. wKind = wKindVal;
  497. }
  498. //
  499. // Manipulating the tree.
  500. //
  501. void AppendChild( CDbCmdTreeNode *pChild );
  502. void InsertChild( CDbCmdTreeNode *pChild );
  503. void AppendSibling( CDbCmdTreeNode *pSibling );
  504. void InsertSibling( CDbCmdTreeNode *pSibling )
  505. {
  506. // Win4Assert( 0 == pSibling->pctNextSibling );
  507. pSibling->pctNextSibling = pctNextSibling;
  508. pctNextSibling = pSibling;
  509. }
  510. CDbCmdTreeNode * RemoveFirstChild( );
  511. private:
  512. //
  513. // To accidentally prevent someone from creating copy constructors
  514. //
  515. CDbCmdTreeNode( const CDbCmdTreeNode & rhs );
  516. CDbCmdTreeNode & operator=( const CDbCmdTreeNode & rhs );
  517. static unsigned SizeInBytes( const WCHAR * pwszStr )
  518. {
  519. if ( 0 != pwszStr )
  520. {
  521. return (wcslen( pwszStr )+1)*sizeof(WCHAR);
  522. }
  523. else
  524. {
  525. return 0;
  526. }
  527. }
  528. };
  529. //+---------------------------------------------------------------------------
  530. //
  531. // Method: CDbCmdTreeNode::operator new
  532. //
  533. // Synopsis: Command tree node allocation via IMalloc::Alloc
  534. //
  535. // Arguments: [size] -
  536. //
  537. // History: 6-06-95 srikants Created
  538. //
  539. // Notes:
  540. //
  541. //----------------------------------------------------------------------------
  542. inline void * CDbCmdTreeNode::operator new( size_t size )
  543. {
  544. return CoTaskMemAlloc( size );
  545. }
  546. //+---------------------------------------------------------------------------
  547. //
  548. // Method: CDbCmdTreeNode::operator new
  549. //
  550. // Synopsis: null allocator
  551. //
  552. // Arguments: [size] -
  553. // [p] -
  554. //
  555. // History: 6-06-95 srikants Created
  556. //
  557. // Notes:
  558. //
  559. //----------------------------------------------------------------------------
  560. inline void * CDbCmdTreeNode::operator new( size_t size, void * p )
  561. {
  562. return( p );
  563. }
  564. //+---------------------------------------------------------------------------
  565. //
  566. // Method: CDbCmdTreeNode::operator delete
  567. //
  568. // Synopsis: Command tree node deallocation via IMalloc::Free
  569. //
  570. // Arguments: [p] -
  571. //
  572. // History: 6-06-95 srikants Created
  573. //
  574. // Notes:
  575. //
  576. //----------------------------------------------------------------------------
  577. inline void CDbCmdTreeNode::operator delete( void * p )
  578. {
  579. CoTaskMemFree( p );
  580. }
  581. //+---------------------------------------------------------------------------
  582. //
  583. // Class: CDbByGuid ()
  584. //
  585. // Purpose:
  586. //
  587. // History: 11-15-95 srikants Created
  588. //
  589. // Notes:
  590. //
  591. //----------------------------------------------------------------------------
  592. class CDbByGuid : public DBBYGUID
  593. {
  594. public:
  595. CDbByGuid()
  596. {
  597. RtlZeroMemory( this, sizeof(DBBYGUID) );
  598. }
  599. CDbByGuid( GUID const & guidIn, ULONG cbInfoIn = 0, const BYTE * pbInfoIn = 0 )
  600. {
  601. guid = guidIn;
  602. cbInfo = cbInfoIn;
  603. if ( 0 != pbInfoIn && 0 != cbInfoIn )
  604. {
  605. pbInfo = (BYTE *) CoTaskMemAlloc( cbInfoIn );
  606. if ( 0 != pbInfo )
  607. RtlCopyMemory( pbInfo, pbInfoIn, cbInfoIn );
  608. }
  609. else
  610. {
  611. pbInfo = 0;
  612. }
  613. }
  614. CDbByGuid( DBBYGUID const & rhs )
  615. {
  616. cbInfo = 0;
  617. pbInfo = 0;
  618. CDbByGuid const * pRhs = (CDbByGuid *) &rhs;
  619. operator=( *pRhs );
  620. }
  621. ~CDbByGuid()
  622. {
  623. _Cleanup();
  624. }
  625. void Marshall( PSerStream & stm ) const;
  626. BOOL UnMarshall( PDeSerStream & stm );
  627. CDbByGuid & operator=( CDbByGuid const & rhs );
  628. //
  629. // Comparators
  630. //
  631. int operator==( CDbByGuid const & rhs ) const;
  632. int operator!=( CDbByGuid const & rhs ) const
  633. {
  634. return !operator==(rhs);
  635. }
  636. //
  637. // Member variable access
  638. //
  639. void SetPropSet( GUID const & guidIn )
  640. {
  641. guid = guidIn;
  642. }
  643. GUID const & GetGuid() const
  644. {
  645. return guid;
  646. }
  647. BOOL IsValid() const
  648. {
  649. return 0 != cbInfo ? 0 != pbInfo : TRUE;
  650. }
  651. DBBYGUID * CastToStruct()
  652. {
  653. return (DBBYGUID *) this;
  654. }
  655. DBBYGUID const * CastToStruct() const
  656. {
  657. return (DBBYGUID const *) this;
  658. }
  659. //
  660. // Memory allocation
  661. //
  662. void * operator new( size_t size )
  663. {
  664. return CoTaskMemAlloc( size );
  665. }
  666. inline void * operator new( size_t size, void * p )
  667. {
  668. return( p );
  669. }
  670. void operator delete( void * p )
  671. {
  672. CoTaskMemFree( p );
  673. }
  674. private:
  675. void _Cleanup()
  676. {
  677. if ( 0 != pbInfo )
  678. {
  679. CoTaskMemFree( pbInfo );
  680. pbInfo = 0;
  681. }
  682. }
  683. };
  684. //+---------------------------------------------------------------------------
  685. //
  686. // Class: CDbParameter
  687. //
  688. // Purpose:
  689. //
  690. // History: 11-15-95 srikants Created
  691. //
  692. // Notes:
  693. //
  694. //----------------------------------------------------------------------------
  695. class CDbParameter : public DBPARAMETER
  696. {
  697. public:
  698. CDbParameter()
  699. {
  700. RtlZeroMemory( this, sizeof(DBPARAMETER) );
  701. }
  702. CDbParameter( const DBPARAMETER & rhs )
  703. {
  704. RtlZeroMemory( this, sizeof(DBPARAMETER) );
  705. Copy( rhs );
  706. }
  707. ~CDbParameter()
  708. {
  709. _Cleanup();
  710. }
  711. BOOL Copy( const DBPARAMETER & rhs );
  712. //
  713. // Memory allocation
  714. //
  715. void * operator new( size_t size )
  716. {
  717. return CoTaskMemAlloc( size );
  718. }
  719. inline void * operator new( size_t size, void * p )
  720. {
  721. return( p );
  722. }
  723. void operator delete( void * p )
  724. {
  725. CoTaskMemFree( p );
  726. }
  727. void Marshall( PSerStream & stm ) const;
  728. BOOL UnMarshall( PDeSerStream & stm );
  729. BOOL IsValid() const
  730. {
  731. return TRUE;
  732. }
  733. DBPARAMETER * CastToStruct()
  734. {
  735. return (DBPARAMETER *) this;
  736. }
  737. DBPARAMETER const * CastToStruct() const
  738. {
  739. return (DBPARAMETER const *) this;
  740. }
  741. private:
  742. void _Cleanup();
  743. };
  744. //+---------------------------------------------------------------------------
  745. //
  746. // Class: CDbPropIDSet
  747. //
  748. // Purpose: Wrap the DBPROPIDSET structure
  749. //
  750. // History: 17 Sep 96 AlanW Created, update for OLE-DB M10
  751. //
  752. // Notes:
  753. //
  754. //----------------------------------------------------------------------------
  755. class CDbPropIDSet : public DBPROPIDSET
  756. {
  757. public:
  758. CDbPropIDSet()
  759. {
  760. RtlZeroMemory( this, sizeof(DBPROPIDSET) );
  761. }
  762. CDbPropIDSet( const DBPROPIDSET & rhs )
  763. {
  764. RtlZeroMemory( this, sizeof(DBPROPIDSET) );
  765. Copy( rhs );
  766. }
  767. BOOL Copy( const DBPROPIDSET & rhs );
  768. ~CDbPropIDSet();
  769. //
  770. // Memory allocation
  771. //
  772. void * operator new( size_t size )
  773. {
  774. return CoTaskMemAlloc( size );
  775. }
  776. inline void * operator new( size_t size, void * p )
  777. {
  778. return( p );
  779. }
  780. void operator delete( void * p )
  781. {
  782. CoTaskMemFree( p );
  783. }
  784. void Marshall( PSerStream & stm ) const;
  785. BOOL UnMarshall( PDeSerStream & stm );
  786. BOOL IsValid() const
  787. {
  788. return TRUE;
  789. }
  790. DBPROPIDSET * CastToStruct()
  791. {
  792. return (DBPROPIDSET *) this;
  793. }
  794. DBPROPIDSET const * CastToStruct() const
  795. {
  796. return (DBPROPIDSET const *) this;
  797. }
  798. private:
  799. };
  800. //+---------------------------------------------------------------------------
  801. //
  802. // Class: CDbProp
  803. //
  804. // Purpose: Wrapper for the DBPROP structure
  805. //
  806. // History: 17 Sep 96 AlanW Created, update for OLE-DB M10
  807. //
  808. // Notes:
  809. //
  810. //----------------------------------------------------------------------------
  811. class CDbProp : public DBPROP
  812. {
  813. public:
  814. CDbProp()
  815. {
  816. RtlZeroMemory( this, sizeof(DBPROP) );
  817. }
  818. CDbProp( const DBPROP & rhs )
  819. {
  820. RtlZeroMemory( this, sizeof(DBPROP) );
  821. Copy( rhs );
  822. }
  823. BOOL Copy( const DBPROP & rhs );
  824. ~CDbProp();
  825. //
  826. // Memory allocation
  827. //
  828. void * operator new( size_t size )
  829. {
  830. return CoTaskMemAlloc( size );
  831. }
  832. inline void * operator new( size_t size, void * p )
  833. {
  834. return p;
  835. }
  836. void operator delete( void * p )
  837. {
  838. CoTaskMemFree( p );
  839. }
  840. void Cleanup( );
  841. void Marshall( PSerStream & stm ) const;
  842. BOOL UnMarshall( PDeSerStream & stm );
  843. BOOL IsValid() const
  844. {
  845. return TRUE;
  846. }
  847. DBPROP * CastToStruct()
  848. {
  849. return (DBPROP *) this;
  850. }
  851. DBPROP const * CastToStruct() const
  852. {
  853. return (DBPROP const *) this;
  854. }
  855. private:
  856. };
  857. //+---------------------------------------------------------------------------
  858. //
  859. // Class: CDbPropSet
  860. //
  861. // Purpose:
  862. //
  863. // History: 11-15-95 srikants Created
  864. // 17 Sep 96 AlanW Update for OLE-DB M10
  865. //
  866. // Notes:
  867. //
  868. //----------------------------------------------------------------------------
  869. class CDbPropSet : public DBPROPSET
  870. {
  871. public:
  872. CDbPropSet()
  873. {
  874. RtlZeroMemory( this, sizeof(DBPROPSET) );
  875. }
  876. CDbPropSet( const DBPROPSET & rhs )
  877. {
  878. RtlZeroMemory( this, sizeof(DBPROPSET) );
  879. Copy( rhs );
  880. }
  881. BOOL Copy( const DBPROPSET & rhs );
  882. ~CDbPropSet();
  883. //
  884. // Memory allocation
  885. //
  886. void * operator new( size_t size )
  887. {
  888. return CoTaskMemAlloc( size );
  889. }
  890. inline void * operator new( size_t size, void * p )
  891. {
  892. return p;
  893. }
  894. void operator delete( void * p )
  895. {
  896. CoTaskMemFree( p );
  897. }
  898. void Marshall( PSerStream & stm ) const;
  899. BOOL UnMarshall( PDeSerStream & stm );
  900. CDbProp * GetProperty( unsigned i ) const
  901. {
  902. if (i < cProperties)
  903. return (CDbProp *)&rgProperties[i];
  904. else
  905. return 0;
  906. }
  907. BOOL IsValid() const
  908. {
  909. return TRUE;
  910. }
  911. DBPROPSET * CastToStruct()
  912. {
  913. return (DBPROPSET *) this;
  914. }
  915. DBPROPSET const * CastToStruct() const
  916. {
  917. return (DBPROPSET const *) this;
  918. }
  919. private:
  920. };
  921. //+---------------------------------------------------------------------------
  922. //
  923. // Class: CDbContentVector
  924. //
  925. // Purpose:
  926. //
  927. // History: 11-15-95 srikants Created
  928. //
  929. // Notes:
  930. //
  931. //----------------------------------------------------------------------------
  932. class CDbContentVector : public DBCONTENTVECTOR
  933. {
  934. public:
  935. CDbContentVector( const CDbContentVector & rhs )
  936. {
  937. lWeight = 0;
  938. RtlCopyMemory(this, rhs.CastToStruct(), sizeof(DBCONTENTVECTOR));
  939. }
  940. CDbContentVector( const DBCONTENTVECTOR & rhs )
  941. {
  942. lWeight = 0;
  943. RtlCopyMemory(this, &rhs, sizeof(DBCONTENTVECTOR));
  944. }
  945. CDbContentVector( DWORD rank = 0 )
  946. {
  947. dwRankingMethod = rank;
  948. lWeight = 0;
  949. }
  950. ~CDbContentVector()
  951. {
  952. }
  953. void SetRankMethod( DWORD rank )
  954. {
  955. dwRankingMethod = rank;
  956. }
  957. LONG GetWeight() const
  958. {
  959. return lWeight;
  960. }
  961. void SetWeight( LONG lWeightIn )
  962. {
  963. lWeight = lWeightIn;
  964. }
  965. ULONG RankMethod() const
  966. {
  967. return (ULONG) dwRankingMethod;
  968. }
  969. DBCONTENTVECTOR * CastToStruct()
  970. {
  971. return (DBCONTENTVECTOR *) this;
  972. }
  973. DBCONTENTVECTOR const * CastToStruct() const
  974. {
  975. return (DBCONTENTVECTOR const *) this;
  976. }
  977. //
  978. // Memory allocation
  979. //
  980. void * operator new( size_t size )
  981. {
  982. return CoTaskMemAlloc( size );
  983. }
  984. inline void * operator new( size_t size, void * p )
  985. {
  986. return( p );
  987. }
  988. void operator delete( void * p )
  989. {
  990. CoTaskMemFree( p );
  991. }
  992. BOOL IsValid() const
  993. {
  994. return TRUE;
  995. }
  996. void Marshall( PSerStream & stm ) const;
  997. BOOL UnMarshall( PDeSerStream & stm );
  998. private:
  999. };
  1000. //+---------------------------------------------------------------------------
  1001. //
  1002. // Class: CDbNumeric
  1003. //
  1004. // Purpose:
  1005. //
  1006. // History: 11-16-95 srikants Created
  1007. //
  1008. // Notes:
  1009. //
  1010. //----------------------------------------------------------------------------
  1011. class CDbNumeric : public DB_NUMERIC
  1012. {
  1013. public:
  1014. CDbNumeric()
  1015. {
  1016. RtlZeroMemory( this, sizeof(DB_NUMERIC) );
  1017. }
  1018. CDbNumeric( const DB_NUMERIC & rhs )
  1019. {
  1020. RtlCopyMemory( this, &rhs, sizeof(DB_NUMERIC) );
  1021. }
  1022. //
  1023. // Memory allocation
  1024. //
  1025. void * operator new( size_t size )
  1026. {
  1027. return CoTaskMemAlloc( size );
  1028. }
  1029. inline void * operator new( size_t size, void * p )
  1030. {
  1031. return( p );
  1032. }
  1033. void operator delete( void * p )
  1034. {
  1035. CoTaskMemFree( p );
  1036. }
  1037. BOOL IsValid() const
  1038. {
  1039. return TRUE;
  1040. }
  1041. //
  1042. // Serialization and DeSerialization.
  1043. //
  1044. void Marshall( PSerStream & stm ) const;
  1045. BOOL UnMarshall( PDeSerStream & stm );
  1046. DB_NUMERIC * CastToStruct()
  1047. {
  1048. return (DB_NUMERIC *) this;
  1049. }
  1050. DB_NUMERIC const * CastToStruct() const
  1051. {
  1052. return (DB_NUMERIC const *) this;
  1053. }
  1054. private:
  1055. };
  1056. //+---------------------------------------------------------------------------
  1057. //
  1058. // Class: CDbColDesc
  1059. //
  1060. // Purpose:
  1061. //
  1062. // History: 6-21-95 srikants Created
  1063. //
  1064. // Notes:
  1065. //
  1066. //----------------------------------------------------------------------------
  1067. class CDbColDesc : protected DBCOLUMNDESC
  1068. {
  1069. public:
  1070. CDbColDesc( DBCOLUMNDESC & colDesc );
  1071. CDbColDesc();
  1072. void Cleanup();
  1073. void Marshall( PSerStream & stm ) const;
  1074. BOOL UnMarshall( PDeSerStream & stm );
  1075. BOOL Copy( CDbColDesc const & rhs );
  1076. DBCOLUMNDESC * CastToStruct() const;
  1077. private:
  1078. CDbColDesc & operator=( CDbColDesc & rhs );
  1079. };
  1080. //+---------------------------------------------------------------------------
  1081. //
  1082. // Class: CDbText
  1083. //
  1084. // Purpose: Wrapper class for DBTEXT
  1085. //
  1086. // History: 6-22-95 srikants Created
  1087. //
  1088. // Notes:
  1089. //
  1090. //----------------------------------------------------------------------------
  1091. class CDbText : public DBTEXT
  1092. {
  1093. public:
  1094. CDbText( DBTEXT const & text )
  1095. {
  1096. Copy( text );
  1097. }
  1098. CDbText()
  1099. {
  1100. RtlZeroMemory( this,sizeof(CDbText) );
  1101. }
  1102. DBTEXT & GetText() const { return (DBTEXT &)*this; }
  1103. BOOL Copy( const DBTEXT & rhs )
  1104. {
  1105. RtlCopyMemory( this, &rhs, sizeof(DBTEXT) );
  1106. pwszText = 0;
  1107. if ( 0 != rhs.pwszText )
  1108. {
  1109. pwszText = CDbCmdTreeNode::AllocAndCopyWString( rhs.pwszText );
  1110. return 0 != pwszText;
  1111. }
  1112. return TRUE;
  1113. }
  1114. void Marshall( PSerStream & stm ) const
  1115. {
  1116. stm.PutGUID( guidDialect );
  1117. CDbCmdTreeNode::PutWString( stm, pwszText );
  1118. stm.PutULong( ulErrorLocator );
  1119. stm.PutULong( ulTokenLength );
  1120. }
  1121. BOOL UnMarshall( PDeSerStream & stm )
  1122. {
  1123. BOOL fSuccess;
  1124. stm.GetGUID( guidDialect );
  1125. pwszText = CDbCmdTreeNode::GetWString( stm, fSuccess );
  1126. if( fSuccess )
  1127. {
  1128. ulErrorLocator = stm.GetULong();
  1129. ulTokenLength = stm.GetULong();
  1130. }
  1131. return fSuccess;
  1132. }
  1133. DBTEXT * CastToStruct()
  1134. {
  1135. return (DBTEXT *) this;
  1136. }
  1137. DBTEXT const * CastToStruct() const
  1138. {
  1139. return (DBTEXT const *) this;
  1140. }
  1141. BOOL IsValid() const { return 0 != pwszText; }
  1142. };
  1143. //+---------------------------------------------------------------------------
  1144. //
  1145. // Class: CDbContent
  1146. //
  1147. // Purpose: Wrapper for DBCONTENT
  1148. //
  1149. // History: 6-22-95 srikants Created
  1150. //
  1151. // Notes:
  1152. //
  1153. //----------------------------------------------------------------------------
  1154. class CDbContent : public DBCONTENT
  1155. {
  1156. public:
  1157. CDbContent( DWORD dwGenerateMethodIn, LONG lWeightIn,
  1158. LCID lcidIn, const WCHAR * pwszPhraseIn )
  1159. {
  1160. dwGenerateMethod = dwGenerateMethodIn;
  1161. lWeight = lWeightIn;
  1162. lcid = lcidIn;
  1163. pwszPhrase = 0;
  1164. SetPhrase( pwszPhraseIn );
  1165. }
  1166. CDbContent()
  1167. {
  1168. RtlZeroMemory( this, sizeof(CDbContent) );
  1169. }
  1170. DBCONTENT & GetDbContent() const { return (DBCONTENT &)*this; }
  1171. BOOL Copy( DBCONTENT const & rhs )
  1172. {
  1173. RtlCopyMemory( this, &rhs, sizeof(DBCONTENT) );
  1174. pwszPhrase = 0;
  1175. if ( 0 != rhs.pwszPhrase )
  1176. {
  1177. pwszPhrase =
  1178. CDbCmdTreeNode::AllocAndCopyWString( rhs.pwszPhrase );
  1179. return 0 != pwszPhrase;
  1180. }
  1181. return TRUE;
  1182. }
  1183. CDbContent ( DBCONTENT const & content )
  1184. {
  1185. Copy( content );
  1186. }
  1187. ~CDbContent()
  1188. {
  1189. if ( 0 != pwszPhrase )
  1190. {
  1191. CoTaskMemFree( pwszPhrase );
  1192. }
  1193. }
  1194. void Marshall( PSerStream & stm ) const
  1195. {
  1196. stm.PutULong( dwGenerateMethod );
  1197. stm.PutLong( lWeight );
  1198. stm.PutULong( lcid );
  1199. CDbCmdTreeNode::PutWString( stm, pwszPhrase );
  1200. }
  1201. BOOL UnMarshall( PDeSerStream & stm )
  1202. {
  1203. BOOL fSuccess = TRUE;
  1204. dwGenerateMethod = stm.GetULong();
  1205. lWeight = stm.GetLong( );
  1206. lcid = stm.GetULong();
  1207. pwszPhrase = CDbCmdTreeNode::GetWString( stm, fSuccess );
  1208. return fSuccess;
  1209. }
  1210. //
  1211. // Data member access and set methods.
  1212. //
  1213. WCHAR const * GetPhrase() const
  1214. {
  1215. return pwszPhrase;
  1216. }
  1217. BOOL SetPhrase( const WCHAR * pwszPhraseIn )
  1218. {
  1219. if ( 0 != pwszPhrase )
  1220. {
  1221. CoTaskMemFree( pwszPhrase );
  1222. }
  1223. pwszPhrase = CDbCmdTreeNode::AllocAndCopyWString( pwszPhraseIn );
  1224. return 0 != pwszPhrase;
  1225. }
  1226. LCID GetLocale() const { return lcid; }
  1227. void SetLocale( LCID lcidIn ) { lcid = lcidIn; }
  1228. LONG GetWeight() const { return lWeight; }
  1229. void SetWeight( LONG weight ) { lWeight = weight; }
  1230. DWORD GetGenerateMethod() const { return dwGenerateMethod; }
  1231. void SetGenerateMethod( DWORD GenerateMethod ) { dwGenerateMethod = GenerateMethod; }
  1232. void Cleanup()
  1233. {
  1234. if ( 0 != pwszPhrase )
  1235. {
  1236. CoTaskMemFree( pwszPhrase );
  1237. pwszPhrase = 0;
  1238. }
  1239. }
  1240. DBCONTENT * CastToStruct()
  1241. {
  1242. return (DBCONTENT *) this;
  1243. }
  1244. DBCONTENT const * CastToStruct() const
  1245. {
  1246. return (DBCONTENT const *) this;
  1247. }
  1248. //
  1249. // Memory allocation
  1250. //
  1251. void * operator new( size_t size )
  1252. {
  1253. return CoTaskMemAlloc( size );
  1254. }
  1255. inline void * operator new( size_t size, void * p )
  1256. {
  1257. return( p );
  1258. }
  1259. void operator delete( void * p )
  1260. {
  1261. CoTaskMemFree( p );
  1262. }
  1263. BOOL IsValid() const
  1264. {
  1265. return 0 != pwszPhrase;
  1266. }
  1267. private:
  1268. };
  1269. //+---------------------------------------------------------------------------
  1270. //
  1271. // Class: CDbContentProximity
  1272. //
  1273. // Purpose: Wrapper for DBCONTENTPROXIMITY
  1274. //
  1275. // History: 11-Aug-97 KrishnaN Created
  1276. //
  1277. // Notes:
  1278. //
  1279. //----------------------------------------------------------------------------
  1280. class CDbContentProximity : public DBCONTENTPROXIMITY
  1281. {
  1282. public:
  1283. CDbContentProximity( DWORD dwProximityUnitIn, ULONG ulProximityDistanceIn, LONG lWeightIn)
  1284. {
  1285. dwProximityUnit = dwProximityUnitIn;
  1286. lWeight = lWeightIn;
  1287. ulProximityDistance = ulProximityDistanceIn;
  1288. }
  1289. CDbContentProximity()
  1290. {
  1291. RtlZeroMemory( this, sizeof(CDbContentProximity) );
  1292. }
  1293. DBCONTENTPROXIMITY & GetDBCONTENTPROXIMITY() const { return (DBCONTENTPROXIMITY &)*this; }
  1294. CDbContentProximity ( DBCONTENTPROXIMITY const & content )
  1295. {
  1296. RtlCopyMemory( this, &content, sizeof(DBCONTENTPROXIMITY) );
  1297. }
  1298. ~CDbContentProximity()
  1299. {
  1300. }
  1301. void Marshall( PSerStream & stm ) const
  1302. {
  1303. stm.PutULong( dwProximityUnit );
  1304. stm.PutULong( ulProximityDistance );
  1305. stm.PutLong( lWeight );
  1306. }
  1307. BOOL UnMarshall( PDeSerStream & stm )
  1308. {
  1309. BOOL fSuccess = TRUE;
  1310. dwProximityUnit = stm.GetULong();
  1311. ulProximityDistance = stm.GetULong();
  1312. lWeight = stm.GetLong( );
  1313. return fSuccess;
  1314. }
  1315. //
  1316. // Data member access and set methods.
  1317. //
  1318. LONG GetWeight() const
  1319. {
  1320. return lWeight;
  1321. }
  1322. void SetWeight( LONG weight )
  1323. {
  1324. lWeight = weight;
  1325. }
  1326. DWORD GetProximityUnit() const
  1327. {
  1328. return dwProximityUnit;
  1329. }
  1330. void SetProximityUnit(DWORD dwProximityUnitIn)
  1331. {
  1332. dwProximityUnit = dwProximityUnitIn;
  1333. }
  1334. ULONG GetProximityDistance() const
  1335. {
  1336. return ulProximityDistance;
  1337. }
  1338. void SetProximityDistance(ULONG ulProximityDistanceIn)
  1339. {
  1340. ulProximityDistance = ulProximityDistanceIn;
  1341. }
  1342. //
  1343. // Conversions
  1344. //
  1345. DBCONTENTPROXIMITY * CastToStruct()
  1346. {
  1347. return (DBCONTENTPROXIMITY *) this;
  1348. }
  1349. DBCONTENTPROXIMITY const * CastToStruct() const
  1350. {
  1351. return (DBCONTENTPROXIMITY const *) this;
  1352. }
  1353. //
  1354. // Memory allocation
  1355. //
  1356. void * operator new( size_t size )
  1357. {
  1358. return CoTaskMemAlloc( size );
  1359. }
  1360. inline void * operator new( size_t size, void * p )
  1361. {
  1362. return( p );
  1363. }
  1364. void operator delete( void * p )
  1365. {
  1366. CoTaskMemFree( p );
  1367. }
  1368. BOOL IsValid() const
  1369. {
  1370. return TRUE;
  1371. }
  1372. private:
  1373. };
  1374. //+---------------------------------------------------------------------------
  1375. //
  1376. // Class: CDbContentScope
  1377. //
  1378. // Purpose: Wrapper for DBCONTENTSCOPE
  1379. //
  1380. // History:
  1381. //
  1382. // Notes:
  1383. //
  1384. //----------------------------------------------------------------------------
  1385. class CDbContentScope : public DBCONTENTSCOPE
  1386. {
  1387. public:
  1388. CDbContentScope( WCHAR * pwszElementValue,
  1389. DWORD dwFlagsIn = SCOPE_FLAG_INCLUDE | SCOPE_FLAG_DEEP )
  1390. {
  1391. // Win4Assert( 0 != pwszElementValue );
  1392. SetValue( pwszElementValue );
  1393. SetFlags( dwFlagsIn );
  1394. }
  1395. CDbContentScope()
  1396. {
  1397. RtlZeroMemory( this, sizeof(CDbContent) );
  1398. }
  1399. DBCONTENTSCOPE & GetDbContent() const { return (DBCONTENTSCOPE &)*this; }
  1400. BOOL Copy( DBCONTENTSCOPE const & rhs )
  1401. {
  1402. RtlCopyMemory( this, &rhs, sizeof(DBCONTENTSCOPE) );
  1403. pwszElementValue = 0;
  1404. if ( 0 != rhs.pwszElementValue )
  1405. {
  1406. pwszElementValue =
  1407. CDbCmdTreeNode::AllocAndCopyWString( rhs.pwszElementValue );
  1408. return 0 != pwszElementValue;
  1409. }
  1410. return TRUE;
  1411. }
  1412. CDbContentScope ( DBCONTENTSCOPE const & contentscp )
  1413. {
  1414. Copy( contentscp );
  1415. }
  1416. ~CDbContentScope()
  1417. {
  1418. if ( 0 != pwszElementValue )
  1419. {
  1420. CoTaskMemFree( pwszElementValue );
  1421. }
  1422. }
  1423. /*
  1424. // won't marshal right now, but use the old method of passing scope
  1425. // to the server.
  1426. void Marshall( PSerStream & stm ) const
  1427. {
  1428. }
  1429. BOOL UnMarshall( PDeSerStream & stm )
  1430. {
  1431. }
  1432. */
  1433. //
  1434. // Data member access and set methods.
  1435. //
  1436. DWORD GetFlags()
  1437. {
  1438. return dwFlags & SCOPE_FLAG_MASK;
  1439. }
  1440. void SetFlags( DWORD dwFlagsIn )
  1441. {
  1442. dwFlags |= dwFlagsIn;
  1443. }
  1444. DWORD GetType()
  1445. {
  1446. return dwFlags & SCOPE_TYPE_MASK;
  1447. }
  1448. void SetType( DWORD dwTypeIn )
  1449. {
  1450. dwFlags |= dwTypeIn;
  1451. }
  1452. WCHAR const * GetValue() const
  1453. {
  1454. return pwszElementValue;
  1455. }
  1456. BOOL SetValue( const WCHAR * pwszElementIn )
  1457. {
  1458. if ( 0 != pwszElementValue )
  1459. {
  1460. CoTaskMemFree( pwszElementValue );
  1461. }
  1462. pwszElementValue = CDbCmdTreeNode::AllocAndCopyWString( pwszElementIn );
  1463. return 0 != pwszElementValue;
  1464. }
  1465. void Cleanup()
  1466. {
  1467. if ( 0 != pwszElementValue )
  1468. {
  1469. CoTaskMemFree( pwszElementValue );
  1470. pwszElementValue = 0;
  1471. }
  1472. }
  1473. DBCONTENTSCOPE * CastToStruct()
  1474. {
  1475. return (DBCONTENTSCOPE *) this;
  1476. }
  1477. DBCONTENTSCOPE const * CastToStruct() const
  1478. {
  1479. return (DBCONTENTSCOPE const *) this;
  1480. }
  1481. //
  1482. // Memory allocation
  1483. //
  1484. void * operator new( size_t size )
  1485. {
  1486. return CoTaskMemAlloc( size );
  1487. }
  1488. inline void * operator new( size_t size, void * p )
  1489. {
  1490. return( p );
  1491. }
  1492. void operator delete( void * p )
  1493. {
  1494. CoTaskMemFree( p );
  1495. }
  1496. BOOL IsValid() const
  1497. {
  1498. return 0 != pwszElementValue;
  1499. }
  1500. };
  1501. //+---------------------------------------------------------------------------
  1502. //
  1503. // Class: CDbContentTable
  1504. //
  1505. // Purpose: Wrapper for DBCONTENTTABLE
  1506. //
  1507. // History:
  1508. //
  1509. // Notes:
  1510. //
  1511. //----------------------------------------------------------------------------
  1512. class CDbContentTable : public DBCONTENTTABLE
  1513. {
  1514. public:
  1515. CDbContentTable( WCHAR * pwszMachine, WCHAR * pwszCatalog )
  1516. {
  1517. // Win4Assert( 0 != pwszMachine );
  1518. // Win4Assert( 0 != pwszCatalog );
  1519. SetMachine( pwszMachine );
  1520. SetCatalog( pwszCatalog );
  1521. }
  1522. CDbContentTable( )
  1523. {
  1524. RtlZeroMemory( this, sizeof(CDbContentTable) );
  1525. }
  1526. DBCONTENTTABLE & GetDbContentTable() const { return (DBCONTENTTABLE &)*this; }
  1527. BOOL Copy( DBCONTENTTABLE const & rhs )
  1528. {
  1529. RtlCopyMemory( this, &rhs, sizeof(DBCONTENTTABLE) );
  1530. pwszMachine = 0;
  1531. pwszCatalog = 0;
  1532. if ( 0 != rhs.pwszMachine )
  1533. {
  1534. pwszMachine =
  1535. CDbCmdTreeNode::AllocAndCopyWString( rhs.pwszMachine );
  1536. if ( 0 != pwszMachine )
  1537. {
  1538. pwszCatalog =
  1539. CDbCmdTreeNode::AllocAndCopyWString( rhs.pwszCatalog );
  1540. }
  1541. return 0 != pwszMachine && 0 != pwszCatalog;
  1542. }
  1543. return TRUE;
  1544. }
  1545. CDbContentTable( DBCONTENTTABLE const & contenttbl )
  1546. {
  1547. Copy( contenttbl );
  1548. }
  1549. ~CDbContentTable()
  1550. {
  1551. if ( 0 != pwszMachine )
  1552. {
  1553. CoTaskMemFree( pwszMachine );
  1554. }
  1555. if ( 0 != pwszCatalog )
  1556. {
  1557. CoTaskMemFree( pwszCatalog );
  1558. }
  1559. }
  1560. /*
  1561. // won't marshal right now, but use the old method of passing scope
  1562. // to the server.
  1563. void Marshall( PSerStream & stm ) const
  1564. {
  1565. }
  1566. BOOL UnMarshall( PDeSerStream & stm )
  1567. {
  1568. }
  1569. */
  1570. //
  1571. // Data member access and set methods.
  1572. //
  1573. WCHAR const * GetMachine() const
  1574. {
  1575. return pwszMachine;
  1576. }
  1577. WCHAR const * GetCatalog() const
  1578. {
  1579. return pwszCatalog;
  1580. }
  1581. BOOL SetMachine( const WCHAR * pwszMachineIn )
  1582. {
  1583. if ( 0 != pwszMachine )
  1584. {
  1585. CoTaskMemFree( pwszMachine );
  1586. }
  1587. pwszMachine = CDbCmdTreeNode::AllocAndCopyWString( pwszMachineIn );
  1588. return 0 != pwszMachine;
  1589. }
  1590. BOOL SetCatalog( const WCHAR * pwszCatalogIn )
  1591. {
  1592. if ( 0 != pwszCatalog )
  1593. {
  1594. CoTaskMemFree( pwszCatalog);
  1595. }
  1596. pwszCatalog = CDbCmdTreeNode::AllocAndCopyWString( pwszCatalogIn );
  1597. return 0 != pwszCatalog;
  1598. }
  1599. void Cleanup()
  1600. {
  1601. if ( 0 != pwszMachine )
  1602. {
  1603. CoTaskMemFree( pwszMachine );
  1604. pwszMachine = 0;
  1605. }
  1606. if ( 0 != pwszCatalog )
  1607. {
  1608. CoTaskMemFree( pwszCatalog );
  1609. pwszCatalog = 0;
  1610. }
  1611. }
  1612. DBCONTENTTABLE * CastToStruct()
  1613. {
  1614. return (DBCONTENTTABLE *) this;
  1615. }
  1616. DBCONTENTTABLE const * CastToStruct() const
  1617. {
  1618. return (DBCONTENTTABLE const *) this;
  1619. }
  1620. //
  1621. // Memory allocation
  1622. //
  1623. void * operator new( size_t size )
  1624. {
  1625. return CoTaskMemAlloc( size );
  1626. }
  1627. inline void * operator new( size_t size, void * p )
  1628. {
  1629. return( p );
  1630. }
  1631. void operator delete( void * p )
  1632. {
  1633. CoTaskMemFree( p );
  1634. }
  1635. BOOL IsValid() const
  1636. {
  1637. return 0 != pwszMachine && 0 != pwszCatalog;
  1638. }
  1639. };
  1640. //+---------------------------------------------------------------------------
  1641. //
  1642. // Class: CDbLike
  1643. //
  1644. // Purpose: Wrapper for DBLIKE
  1645. //
  1646. // History: 13-Aug-97 KrishnaN Created
  1647. //
  1648. // Notes:
  1649. //
  1650. //----------------------------------------------------------------------------
  1651. class CDbLike : public DBLIKE
  1652. {
  1653. public:
  1654. CDbLike( GUID const & guidDialectIn, LONG lWeightIn )
  1655. {
  1656. lWeight = lWeightIn;
  1657. guidDialect = guidDialectIn;
  1658. }
  1659. CDbLike()
  1660. {
  1661. RtlZeroMemory( this, sizeof(CDbLike) );
  1662. }
  1663. DBLIKE & GetDbLike() const { return (DBLIKE &)*this; }
  1664. CDbLike ( DBLIKE const & like )
  1665. {
  1666. RtlCopyMemory( this, &like, sizeof(DBLIKE) );
  1667. }
  1668. ~CDbLike()
  1669. {
  1670. }
  1671. void Marshall( PSerStream & stm ) const
  1672. {
  1673. stm.PutGUID( guidDialect );
  1674. stm.PutLong( lWeight );
  1675. }
  1676. BOOL UnMarshall( PDeSerStream & stm )
  1677. {
  1678. BOOL fSuccess = TRUE;
  1679. stm.GetGUID(guidDialect);
  1680. lWeight = stm.GetLong( );
  1681. return fSuccess;
  1682. }
  1683. //
  1684. // Data member access and set methods.
  1685. //
  1686. LONG GetWeight() const
  1687. {
  1688. return lWeight;
  1689. }
  1690. void SetWeight( LONG weight )
  1691. {
  1692. lWeight = weight;
  1693. }
  1694. GUID const & GetDialect() const
  1695. {
  1696. return guidDialect;
  1697. }
  1698. void SetDialect(GUID const & guidDialectIn)
  1699. {
  1700. guidDialect = guidDialectIn;
  1701. }
  1702. //
  1703. // Conversions
  1704. //
  1705. DBLIKE * CastToStruct()
  1706. {
  1707. return (DBLIKE *) this;
  1708. }
  1709. DBLIKE const * CastToStruct() const
  1710. {
  1711. return (DBLIKE const *) this;
  1712. }
  1713. //
  1714. // Memory allocation
  1715. //
  1716. void * operator new( size_t size )
  1717. {
  1718. return CoTaskMemAlloc( size );
  1719. }
  1720. inline void * operator new( size_t size, void * p )
  1721. {
  1722. return( p );
  1723. }
  1724. void operator delete( void * p )
  1725. {
  1726. CoTaskMemFree( p );
  1727. }
  1728. BOOL IsValid() const
  1729. {
  1730. return (lWeight >= 0);
  1731. }
  1732. private:
  1733. };
  1734. //+---------------------------------------------------------------------------
  1735. //
  1736. // Class: CDbSortInfo
  1737. //
  1738. // Purpose: WRAPPER for DBSORTINFO
  1739. //
  1740. // History: 6-22-95 srikants Created
  1741. //
  1742. // Notes:
  1743. //
  1744. //----------------------------------------------------------------------------
  1745. class CDbSortInfo : public DBSORTINFO
  1746. {
  1747. public:
  1748. CDbSortInfo( BOOL fDescending = FALSE, LCID lcidIn = 0 )
  1749. {
  1750. fDesc = fDescending;
  1751. lcid = lcidIn;
  1752. }
  1753. CDbSortInfo( DBSORTINFO & sortInfo ) : DBSORTINFO(sortInfo) {}
  1754. BOOL Copy( DBSORTINFO const & rhs )
  1755. {
  1756. *(DBSORTINFO *)this = rhs;
  1757. return TRUE;
  1758. }
  1759. void Marshall( PSerStream & stm ) const
  1760. {
  1761. stm.PutULong( lcid );
  1762. stm.PutULong( fDesc );
  1763. }
  1764. BOOL UnMarshall( PDeSerStream & stm )
  1765. {
  1766. lcid = stm.GetULong();
  1767. fDesc = stm.GetULong();
  1768. return TRUE;
  1769. }
  1770. DBSORTINFO & Get() const { return (DBSORTINFO &)*this; }
  1771. LCID GetLocale() const { return lcid; }
  1772. BOOL GetDirection() const { return fDesc; }
  1773. void SetLocale(LCID lcidIn) { lcid = lcidIn; }
  1774. void SetDirection(BOOL fDescIn) { fDesc = fDescIn; }
  1775. //
  1776. // Memory allocation
  1777. //
  1778. void * operator new( size_t size )
  1779. {
  1780. return CoTaskMemAlloc( size );
  1781. }
  1782. inline void * operator new( size_t size, void * p )
  1783. {
  1784. return( p );
  1785. }
  1786. void operator delete( void * p )
  1787. {
  1788. CoTaskMemFree( p );
  1789. }
  1790. BOOL IsValid() const
  1791. {
  1792. return TRUE;
  1793. }
  1794. DBSORTINFO * CastToStruct()
  1795. {
  1796. return (DBSORTINFO *) this;
  1797. }
  1798. DBSORTINFO const * CastToStruct() const
  1799. {
  1800. return (DBSORTINFO const *) this;
  1801. }
  1802. private:
  1803. };
  1804. //+---------------------------------------------------------------------------
  1805. //
  1806. // Class: CDbGroupInfo
  1807. //
  1808. // Purpose: WRAPPER for DBGROUPINFO
  1809. //
  1810. // History: 6-22-95 srikants Created
  1811. //
  1812. // Notes:
  1813. //
  1814. //----------------------------------------------------------------------------
  1815. class CDbGroupInfo : public DBGROUPINFO
  1816. {
  1817. public:
  1818. CDbGroupInfo( DBGROUPINFO & groupInfo ) : DBGROUPINFO(groupInfo) {}
  1819. CDbGroupInfo()
  1820. {
  1821. RtlZeroMemory( this, sizeof(CDbGroupInfo) );
  1822. }
  1823. DBGROUPINFO & Get() const { return *(DBGROUPINFO *)this; }
  1824. BOOL Copy( DBGROUPINFO const & rhs )
  1825. {
  1826. *(DBGROUPINFO *)this = rhs;
  1827. return TRUE;
  1828. }
  1829. void Marshall( PSerStream & stm ) const
  1830. {
  1831. stm.PutULong( lcid );
  1832. }
  1833. BOOL UnMarshall( PDeSerStream & stm )
  1834. {
  1835. lcid = stm.GetULong();
  1836. return TRUE;
  1837. }
  1838. DBGROUPINFO * CastToStruct()
  1839. {
  1840. return (DBGROUPINFO *) this;
  1841. }
  1842. DBGROUPINFO const * CastToStruct() const
  1843. {
  1844. return (DBGROUPINFO const *) this;
  1845. }
  1846. //
  1847. // Memory allocation
  1848. //
  1849. void * operator new( size_t size )
  1850. {
  1851. return CoTaskMemAlloc( size );
  1852. }
  1853. inline void * operator new( size_t size, void * p )
  1854. {
  1855. return( p );
  1856. }
  1857. void operator delete( void * p )
  1858. {
  1859. CoTaskMemFree( p );
  1860. }
  1861. BOOL IsValid() const
  1862. {
  1863. return TRUE;
  1864. }
  1865. private:
  1866. };
  1867. //+---------------------------------------------------------------------------
  1868. //
  1869. // Class: CDbColumnNode
  1870. //
  1871. // Purpose: A DBCOMMANDTREE node representing a column
  1872. //
  1873. // History: 6-07-95 srikants Created
  1874. //
  1875. // Notes:
  1876. //
  1877. //----------------------------------------------------------------------------
  1878. class CDbColumnNode : public CDbCmdTreeNode
  1879. {
  1880. public:
  1881. //
  1882. // Constructors
  1883. //
  1884. CDbColumnNode() : CDbCmdTreeNode(DBOP_column_name)
  1885. {
  1886. wKind = DBVALUEKIND_ID;
  1887. CDbColId * pTemp = new CDbColId();
  1888. if ( pTemp )
  1889. {
  1890. value.pdbidValue = pTemp->CastToStruct();
  1891. }
  1892. }
  1893. CDbColumnNode( GUID const & guidPropSet, PROPID pidProperty )
  1894. : CDbCmdTreeNode(DBOP_column_name)
  1895. {
  1896. wKind = DBVALUEKIND_ID;
  1897. CDbColId * pTemp = new CDbColId( guidPropSet, pidProperty );
  1898. if ( pTemp )
  1899. {
  1900. value.pdbidValue = pTemp->CastToStruct();
  1901. }
  1902. }
  1903. CDbColumnNode( GUID const & guidPropSet, WCHAR const * wcsProperty );
  1904. // The fIMeanIt param is to avoid confusion when methods expect
  1905. // a CDbColumnNode, a DBID is passed, and automatically coerced
  1906. // but the memory allocation not checked.
  1907. CDbColumnNode( DBID const & propSpec, BOOL fIMeanIt );
  1908. //
  1909. // Copy constructors/assignment/clone
  1910. //
  1911. CDbColumnNode( CDbColumnNode const & Property )
  1912. : CDbCmdTreeNode(DBOP_column_name)
  1913. {
  1914. wKind = DBVALUEKIND_ID;
  1915. CDbColId* pTemp = new CDbColId();
  1916. if ( pTemp )
  1917. {
  1918. value.pdbidValue = pTemp->CastToStruct();
  1919. operator=( Property );
  1920. }
  1921. }
  1922. CDbColumnNode & operator=( CDbColumnNode const & rhs )
  1923. {
  1924. *(GetId()) = *(rhs.GetId());
  1925. return *this;
  1926. }
  1927. //
  1928. // Comparators
  1929. //
  1930. int operator==( CDbColumnNode const & rhs ) const
  1931. {
  1932. return *(GetId()) == *(rhs.GetId());
  1933. }
  1934. int operator!=( CDbColumnNode const & prop ) const
  1935. {
  1936. return !operator==(prop);
  1937. }
  1938. //
  1939. // Member variable access
  1940. //
  1941. void SetPropSet( GUID const & guidPropSet )
  1942. {
  1943. GetId()->SetPropSet( guidPropSet );
  1944. }
  1945. GUID const & GetPropSet() const
  1946. {
  1947. return GetId()->GetPropSet();
  1948. }
  1949. void SetProperty( PROPID pidProperty )
  1950. {
  1951. GetId()->SetProperty( pidProperty );
  1952. }
  1953. BOOL SetProperty( WCHAR const * wcsProperty )
  1954. {
  1955. return GetId()->SetProperty( wcsProperty );
  1956. }
  1957. WCHAR const * GetPropertyName() const
  1958. {
  1959. return GetId()->GetPropertyName();
  1960. }
  1961. PROPID GetPropertyPropid() const
  1962. {
  1963. return GetId()->GetPropertyPropid();
  1964. }
  1965. // PROPSPEC GetPropSpec() const;
  1966. BOOL IsPropertyName() const
  1967. {
  1968. return GetId()->IsPropertyName();
  1969. }
  1970. BOOL IsPropertyPropid() const
  1971. {
  1972. return GetId()->IsPropertyPropid();
  1973. }
  1974. void SetCommandType( DBCOMMANDOP opVal )
  1975. {
  1976. CDbCmdTreeNode::SetCommandType( opVal );
  1977. }
  1978. BOOL IsValid() const
  1979. {
  1980. CDbColId const * pId = GetId();
  1981. return (0 != pId) ? pId->IsValid() : FALSE;
  1982. }
  1983. CDbColId * GetId()
  1984. {
  1985. return (CDbColId *) value.pdbidValue;
  1986. }
  1987. CDbColId const * GetId() const
  1988. {
  1989. return (CDbColId const *) value.pdbidValue;
  1990. }
  1991. private:
  1992. };
  1993. //+---------------------------------------------------------------------------
  1994. //
  1995. // Class: CDbScalarValue
  1996. //
  1997. // Purpose: A DBCOMMANDTREE node representing a scalar constant
  1998. //
  1999. // History: 6-07-95 srikants Created
  2000. //
  2001. // Notes:
  2002. //
  2003. //----------------------------------------------------------------------------
  2004. class CDbScalarValue : public CDbCmdTreeNode
  2005. {
  2006. public:
  2007. CDbScalarValue( DBCOMMANDOP opVal = DBOP_scalar_constant ) :
  2008. CDbCmdTreeNode( opVal )
  2009. {
  2010. }
  2011. CDbScalarValue( const CStorageVariant & val ) :
  2012. CDbCmdTreeNode( DBOP_scalar_constant, DBVALUEKIND_VARIANT )
  2013. {
  2014. CStorageVariant * pTemp = new CStorageVariant( val );
  2015. if ( 0 != pTemp && !pTemp->IsValid() )
  2016. {
  2017. delete pTemp;
  2018. pTemp = 0;
  2019. }
  2020. if ( pTemp )
  2021. {
  2022. value.pvarValue = (VARIANT *) (void *)pTemp;
  2023. }
  2024. }
  2025. void SetValue( const CStorageVariant & val )
  2026. {
  2027. CStorageVariant * lhs = _CreateOrGetStorageVariant();
  2028. if ( 0 != lhs )
  2029. {
  2030. *lhs = val;
  2031. }
  2032. }
  2033. void SetValue( double dValue )
  2034. {
  2035. CStorageVariant * pTemp = _GetStorageVariant();
  2036. if ( 0 != pTemp )
  2037. {
  2038. *pTemp = dValue;
  2039. }
  2040. else
  2041. {
  2042. CleanupValue();
  2043. wKind = DBVALUEKIND_R8;
  2044. value.dblValue = dValue;
  2045. }
  2046. }
  2047. void SetValue( ULONG ulValue )
  2048. {
  2049. CStorageVariant * lhs = _GetStorageVariant();
  2050. if ( 0 != lhs )
  2051. {
  2052. lhs->SetUI4(ulValue);
  2053. }
  2054. else
  2055. {
  2056. CleanupValue();
  2057. wKind = DBVALUEKIND_UI4;
  2058. value.ulValue = ulValue;
  2059. }
  2060. }
  2061. void SetValue( LONG lValue )
  2062. {
  2063. CStorageVariant * lhs = _GetStorageVariant();
  2064. if ( 0 != lhs )
  2065. {
  2066. *lhs = lValue;
  2067. }
  2068. else
  2069. {
  2070. CleanupValue();
  2071. wKind = DBVALUEKIND_I4;
  2072. value.lValue = lValue;
  2073. }
  2074. }
  2075. void SetValue( LARGE_INTEGER llValue )
  2076. {
  2077. CStorageVariant * lhs = _GetStorageVariant();
  2078. if ( 0 != lhs )
  2079. {
  2080. *lhs = llValue;
  2081. }
  2082. else
  2083. {
  2084. CleanupValue();
  2085. wKind = DBVALUEKIND_I8;
  2086. value.llValue = (hyper) llValue.QuadPart;
  2087. }
  2088. }
  2089. void SetValue( ULARGE_INTEGER ullValue )
  2090. {
  2091. CStorageVariant * lhs = _GetStorageVariant();
  2092. if ( 0 != lhs )
  2093. {
  2094. lhs->SetUI8(ullValue);
  2095. }
  2096. else
  2097. {
  2098. CleanupValue();
  2099. wKind = DBVALUEKIND_UI8;
  2100. value.ullValue = (unsigned hyper) ullValue.QuadPart;
  2101. }
  2102. }
  2103. void SetValue( FILETIME ftValue )
  2104. {
  2105. CStorageVariant * lhs = _CreateOrGetStorageVariant();
  2106. if ( 0 != lhs )
  2107. {
  2108. *lhs = ftValue;
  2109. }
  2110. }
  2111. void SetValue( CY CyValue )
  2112. {
  2113. CStorageVariant * lhs = _GetStorageVariant();
  2114. if ( 0 != lhs )
  2115. {
  2116. *lhs = CyValue;
  2117. }
  2118. else
  2119. {
  2120. CleanupValue();
  2121. wKind = DBVALUEKIND_CY;
  2122. value.cyValue = CyValue;
  2123. }
  2124. }
  2125. void SetValue( float fValue )
  2126. {
  2127. CStorageVariant * lhs = _GetStorageVariant();
  2128. if ( 0 != lhs )
  2129. {
  2130. *lhs = fValue;
  2131. }
  2132. else
  2133. {
  2134. CleanupValue();
  2135. wKind = DBVALUEKIND_R4;
  2136. value.flValue = fValue;
  2137. }
  2138. }
  2139. void SetValue( SHORT sValue )
  2140. {
  2141. CStorageVariant * lhs = _GetStorageVariant();
  2142. if ( 0 != lhs )
  2143. {
  2144. *lhs = sValue;
  2145. }
  2146. else
  2147. {
  2148. CleanupValue();
  2149. wKind = DBVALUEKIND_I2;
  2150. value.sValue = sValue;
  2151. }
  2152. }
  2153. void SetValue( USHORT usValue )
  2154. {
  2155. CStorageVariant * lhs = _GetStorageVariant();
  2156. if ( 0 != lhs )
  2157. {
  2158. *lhs = usValue;
  2159. }
  2160. else
  2161. {
  2162. CleanupValue();
  2163. wKind = DBVALUEKIND_UI2;
  2164. value.usValue = usValue;
  2165. }
  2166. }
  2167. void SetDate ( DATE dValue )
  2168. {
  2169. CStorageVariant * lhs = _GetStorageVariant();
  2170. if ( 0 != lhs )
  2171. {
  2172. *lhs = dValue;
  2173. }
  2174. else
  2175. {
  2176. CleanupValue();
  2177. wKind = DBVALUEKIND_DATE;
  2178. value.dateValue = dValue;
  2179. }
  2180. }
  2181. void SetBOOL( BOOL fValue )
  2182. {
  2183. CStorageVariant * lhs = _GetStorageVariant();
  2184. if ( 0 != lhs )
  2185. {
  2186. lhs->SetBOOL((SHORT)fValue);
  2187. }
  2188. else
  2189. {
  2190. CleanupValue();
  2191. wKind = DBVALUEKIND_BOOL;
  2192. value.fValue = fValue;
  2193. }
  2194. }
  2195. void SetValue( BLOB & bValue )
  2196. {
  2197. CStorageVariant * lhs = _CreateOrGetStorageVariant();
  2198. if ( 0 != lhs )
  2199. {
  2200. *lhs = bValue;
  2201. }
  2202. }
  2203. void SetValue( WCHAR * pwcsValue )
  2204. {
  2205. CStorageVariant * lhs = _CreateOrGetStorageVariant();
  2206. if ( 0 != lhs )
  2207. {
  2208. *lhs = pwcsValue;
  2209. }
  2210. }
  2211. void SetValue( GUID * pguidValue)
  2212. {
  2213. CStorageVariant * lhs = _CreateOrGetStorageVariant();
  2214. if ( 0 != lhs )
  2215. {
  2216. *lhs = pguidValue;
  2217. }
  2218. }
  2219. void Value( CStorageVariant & valOut );
  2220. BOOL IsValid() const
  2221. {
  2222. CStorageVariant const * pVar = (CStorageVariant const *) _GetStorageVariant();
  2223. return ( ( 0 != pVar ) &&
  2224. ( pVar->IsValid() ) );
  2225. }
  2226. private:
  2227. CStorageVariant * _GetStorageVariant() const
  2228. {
  2229. if ( DBVALUEKIND_VARIANT == wKind )
  2230. {
  2231. return CastToStorageVariant( *value.pvarValue );
  2232. }
  2233. else
  2234. return 0;
  2235. }
  2236. CStorageVariant * _CreateOrGetStorageVariant()
  2237. {
  2238. CStorageVariant * pTemp = _GetStorageVariant();
  2239. if ( 0 != pTemp )
  2240. {
  2241. return pTemp;
  2242. }
  2243. CleanupValue();
  2244. wKind = DBVALUEKIND_VARIANT;
  2245. pTemp = new CStorageVariant();
  2246. value.pvarValue = (VARIANT *) (void *) pTemp;
  2247. return pTemp;
  2248. }
  2249. };
  2250. #define DBTABLEID_NAME L"Table"
  2251. //+---------------------------------------------------------------------------
  2252. //
  2253. // Class: CDbTableId
  2254. //
  2255. // Purpose:
  2256. //
  2257. // History: 6-15-95 srikants Created
  2258. //
  2259. // Notes:
  2260. //
  2261. //----------------------------------------------------------------------------
  2262. class CDbTableId: public CDbCmdTreeNode
  2263. {
  2264. public:
  2265. CDbTableId(const LPWSTR pwszName = DBTABLEID_NAME)
  2266. : CDbCmdTreeNode( DBOP_table_name )
  2267. {
  2268. wKind = DBVALUEKIND_WSTR;
  2269. value.pwszValue = CDbCmdTreeNode::AllocAndCopyWString( pwszName );
  2270. }
  2271. BOOL IsValid() const
  2272. {
  2273. return 0 != value.pwszValue;
  2274. }
  2275. LPWSTR GetTableName() const
  2276. {
  2277. if (wKind == DBVALUEKIND_WSTR)
  2278. return value.pwszValue;
  2279. else
  2280. return 0;
  2281. }
  2282. };
  2283. //+---------------------------------------------------------------------------
  2284. //
  2285. // Class: CDbSelectNode
  2286. //
  2287. // Purpose:
  2288. //
  2289. // History: 6-15-95 srikants Created
  2290. //
  2291. // Notes:
  2292. //
  2293. //----------------------------------------------------------------------------
  2294. class CDbSelectNode : public CDbCmdTreeNode
  2295. {
  2296. public:
  2297. CDbSelectNode( );
  2298. BOOL AddRestriction( CDbCmdTreeNode * pRestr )
  2299. {
  2300. if ( IsValid() &&
  2301. GetFirstChild() &&
  2302. GetFirstChild()->GetNextSibling() == 0 )
  2303. {
  2304. AppendChild( pRestr );
  2305. return TRUE;
  2306. }
  2307. else
  2308. {
  2309. return FALSE;
  2310. }
  2311. }
  2312. BOOL SetRestriction( CDbCmdTreeNode * pRestr );
  2313. BOOL IsValid() const
  2314. {
  2315. return 0 != GetFirstChild() &&
  2316. GetFirstChild()->IsOpValid( DBOP_table_name );
  2317. }
  2318. };
  2319. //+---------------------------------------------------------------------------
  2320. //
  2321. // Class: CDbListAnchor
  2322. //
  2323. // Purpose:
  2324. //
  2325. // History: 6-15-95 srikants Created
  2326. //
  2327. // Notes:
  2328. //
  2329. //----------------------------------------------------------------------------
  2330. class CDbListAnchor : public CDbCmdTreeNode
  2331. {
  2332. public:
  2333. CDbListAnchor( DBCOMMANDOP opVal, WORD wType = DBVALUEKIND_EMPTY )
  2334. : CDbCmdTreeNode( opVal, wType ) {}
  2335. protected:
  2336. BOOL AppendList( CDbCmdTreeNode* pListElement );
  2337. BOOL AppendListElement( CDbCmdTreeNode* pListElement );
  2338. BOOL AppendListElement( DBCOMMANDOP eleType,
  2339. DBID const & PropSpec);
  2340. BOOL AppendListElement( DBCOMMANDOP eleType, const CDbColumnNode & propSpec )
  2341. {
  2342. CDbColumnNode * pTemp = new CDbColumnNode( propSpec );
  2343. if ( 0 != pTemp )
  2344. {
  2345. if (!_AppendListElement( eleType, pTemp ) )
  2346. delete pTemp;
  2347. else
  2348. return TRUE;
  2349. }
  2350. return FALSE;
  2351. }
  2352. CDbCmdTreeNode* AcquireList( )
  2353. {
  2354. return AcquireChildren();
  2355. }
  2356. void FreeList( )
  2357. {
  2358. FreeChildren();
  2359. }
  2360. BOOL SetList( CDbCmdTreeNode* pListElement )
  2361. {
  2362. if (_IsValidListElement( pListElement->op ) &&
  2363. 0 == GetFirstChild() )
  2364. {
  2365. SetChildren( pListElement );
  2366. return TRUE;
  2367. }
  2368. return FALSE;
  2369. }
  2370. private:
  2371. BOOL _IsValidListElement( DBCOMMANDOP eleType ) const
  2372. {
  2373. // NOTE: it might work to just return (op + 1 == eleType)
  2374. if ( op == DBOP_sort_list_anchor && eleType == DBOP_sort_list_element )
  2375. {
  2376. return TRUE;
  2377. }
  2378. else if ( op == DBOP_project_list_anchor && eleType == DBOP_project_list_element )
  2379. {
  2380. return TRUE;
  2381. }
  2382. return FALSE;
  2383. }
  2384. BOOL _AppendListElement( DBCOMMANDOP eleType, CDbColumnNode * pColNode );
  2385. };
  2386. //+---------------------------------------------------------------------------
  2387. //
  2388. // Class: CDbProjectListAnchor
  2389. //
  2390. // Purpose:
  2391. //
  2392. // History: 6-15-95 srikants Created
  2393. //
  2394. // Notes: This class is required by the implementation, but should
  2395. // be unneeded by clients
  2396. //
  2397. //----------------------------------------------------------------------------
  2398. class CDbProjectListElement;
  2399. class CDbProjectListAnchor : public CDbListAnchor
  2400. {
  2401. friend class CDbNestingNode;
  2402. public:
  2403. CDbProjectListAnchor() : CDbListAnchor( DBOP_project_list_anchor ) {}
  2404. BOOL AppendListElement( DBID const & propSpec, LPWSTR pwszName = 0 );
  2405. BOOL AppendListElement( CDbColumnNode const & propSpec )
  2406. {
  2407. return CDbListAnchor::AppendListElement( DBOP_project_list_element,
  2408. propSpec );
  2409. }
  2410. void AppendSibling(CDbCmdTreeNode *pSibling)
  2411. {
  2412. CDbCmdTreeNode::AppendSibling(pSibling);
  2413. }
  2414. void InsertSibling(CDbCmdTreeNode *pSibling)
  2415. {
  2416. CDbCmdTreeNode::InsertSibling(pSibling);
  2417. }
  2418. };
  2419. //+---------------------------------------------------------------------------
  2420. //
  2421. // Class: CDbProjectListElement
  2422. //
  2423. // Purpose:
  2424. //
  2425. // History: 27 Nov 1996 AlanW Created
  2426. //
  2427. // Notes: This class is required by the implementation, but should
  2428. // be unneeded by clients
  2429. //
  2430. //----------------------------------------------------------------------------
  2431. class CDbProjectListElement : public CDbCmdTreeNode
  2432. {
  2433. public:
  2434. CDbProjectListElement( ) :
  2435. CDbCmdTreeNode( DBOP_project_list_element ) { }
  2436. BOOL SetName( LPWSTR pwszColumnName )
  2437. {
  2438. if ( 0 != value.pwszValue )
  2439. {
  2440. CoTaskMemFree( value.pwszValue );
  2441. }
  2442. value.pwszValue = CDbCmdTreeNode::AllocAndCopyWString( pwszColumnName );
  2443. if ( 0 == value.pwszValue )
  2444. wKind = DBVALUEKIND_EMPTY;
  2445. else
  2446. wKind = DBVALUEKIND_WSTR;
  2447. return 0 == pwszColumnName || 0 != value.pwszValue;
  2448. }
  2449. LPWSTR GetName( ) const
  2450. {
  2451. return value.pwszValue;
  2452. }
  2453. BOOL SetColumn(CDbColumnNode * pCol)
  2454. {
  2455. if (GetColumn())
  2456. {
  2457. delete RemoveFirstChild();
  2458. }
  2459. InsertChild( pCol );
  2460. return TRUE;
  2461. }
  2462. CDbColumnNode * GetColumn() const
  2463. {
  2464. return (CDbColumnNode *)GetFirstChild();
  2465. }
  2466. BOOL IsValid() const
  2467. {
  2468. return (DBVALUEKIND_EMPTY == wKind ||
  2469. (DBVALUEKIND_WSTR == wKind && 0 != value.pwszValue) ) &&
  2470. 0 != GetFirstChild() &&
  2471. GetColumn()->IsValid( );
  2472. }
  2473. private:
  2474. };
  2475. //+---------------------------------------------------------------------------
  2476. //
  2477. // Class: CDbProjectNode
  2478. //
  2479. // Purpose:
  2480. //
  2481. // History: 6-15-95 srikants Created
  2482. //
  2483. // Notes:
  2484. //
  2485. //----------------------------------------------------------------------------
  2486. class CDbProjectNode : public CDbCmdTreeNode
  2487. {
  2488. public:
  2489. CDbProjectNode( )
  2490. : CDbCmdTreeNode( DBOP_project )
  2491. {
  2492. }
  2493. BOOL AddProjectColumn( DBID const & propSpec, LPWSTR pwszName = 0 )
  2494. {
  2495. CDbProjectListAnchor * pAnchor = _FindOrAddAnchor();
  2496. if (pAnchor)
  2497. return pAnchor->AppendListElement( propSpec, pwszName );
  2498. else
  2499. return FALSE;
  2500. }
  2501. BOOL AddProjectColumn( CDbColumnNode const & propSpec )
  2502. {
  2503. CDbProjectListAnchor * pAnchor = _FindOrAddAnchor();
  2504. if (pAnchor)
  2505. return pAnchor->AppendListElement( propSpec );
  2506. else
  2507. return FALSE;
  2508. }
  2509. BOOL AddTable( CDbCmdTreeNode * pTable )
  2510. {
  2511. if ( 0 == GetFirstChild() ||
  2512. 0 == GetFirstChild()->GetNextSibling())
  2513. {
  2514. InsertChild(pTable);
  2515. return TRUE;
  2516. }
  2517. return FALSE;
  2518. }
  2519. BOOL AddList( CDbProjectListAnchor * pList )
  2520. {
  2521. if ( 0 == GetFirstChild() ||
  2522. 0 == GetFirstChild()->GetNextSibling())
  2523. {
  2524. AppendChild(pList);
  2525. return TRUE;
  2526. }
  2527. return FALSE;
  2528. }
  2529. private:
  2530. CDbProjectListAnchor * _FindOrAddAnchor();
  2531. };
  2532. //+---------------------------------------------------------------------------
  2533. //
  2534. // Class: CDbSortListAnchor
  2535. //
  2536. // Purpose:
  2537. //
  2538. // History: 6-15-95 srikants Created
  2539. //
  2540. // Notes: This class is required by the implementation, but should
  2541. // be unneeded by clients
  2542. //
  2543. //----------------------------------------------------------------------------
  2544. class CDbSortListElement;
  2545. class CDbSortListAnchor : public CDbListAnchor
  2546. {
  2547. public:
  2548. CDbSortListAnchor() : CDbListAnchor( DBOP_sort_list_anchor ) {}
  2549. inline BOOL AppendList( CDbSortListElement* pListElement );
  2550. inline BOOL AppendListElement( CDbSortListElement* pListElement );
  2551. };
  2552. //+---------------------------------------------------------------------------
  2553. //
  2554. // Class: CDbSortListElement
  2555. //
  2556. // Purpose:
  2557. //
  2558. // History: 17 Aug 1995 AlanW Created
  2559. //
  2560. // Notes: This class is required by the implementation, but should
  2561. // be unneeded by clients
  2562. //
  2563. //----------------------------------------------------------------------------
  2564. class CDbSortListElement : public CDbCmdTreeNode
  2565. {
  2566. public:
  2567. CDbSortListElement( BOOL fDescending = FALSE, LCID locale = 0 ) :
  2568. CDbCmdTreeNode( DBOP_sort_list_element,
  2569. DBVALUEKIND_SORTINFO )
  2570. {
  2571. value.pdbsrtinfValue = new CDbSortInfo( fDescending, locale );
  2572. }
  2573. void SetDirection( BOOL fDescending )
  2574. {
  2575. GetSortInfo().SetDirection( fDescending );
  2576. }
  2577. void SetLocale( LCID locale )
  2578. {
  2579. GetSortInfo().SetLocale(locale);
  2580. }
  2581. BOOL GetDirection( ) const
  2582. {
  2583. return GetSortInfo().GetDirection();
  2584. }
  2585. LCID GetLocale( ) const
  2586. {
  2587. return GetSortInfo().GetLocale();
  2588. }
  2589. void AddColumn( CDbCmdTreeNode * pCol )
  2590. {
  2591. InsertChild( pCol );
  2592. }
  2593. BOOL IsValid() const
  2594. {
  2595. return 0 != value.pdbsrtinfValue;
  2596. }
  2597. CDbSortInfo & GetSortInfo()
  2598. {
  2599. return *((CDbSortInfo *) value.pdbsrtinfValue);
  2600. }
  2601. CDbSortInfo const & GetSortInfo() const
  2602. {
  2603. return *((CDbSortInfo const *) value.pdbsrtinfValue);
  2604. }
  2605. private:
  2606. };
  2607. //+---------------------------------------------------------------------------
  2608. //
  2609. // Class: CDbSortNode
  2610. //
  2611. // Purpose:
  2612. //
  2613. // History: 6-15-95 srikants Created
  2614. //
  2615. // Notes:
  2616. //
  2617. //----------------------------------------------------------------------------
  2618. class CDbSortKey; // forward referenced
  2619. class CDbSortNode : public CDbCmdTreeNode
  2620. {
  2621. public:
  2622. CDbSortNode() : CDbCmdTreeNode( DBOP_sort ) {}
  2623. BOOL AddTable( CDbCmdTreeNode * pTable )
  2624. {
  2625. if ( 0 == GetFirstChild() ||
  2626. 0 == GetFirstChild()->GetNextSibling())
  2627. {
  2628. InsertChild(pTable);
  2629. return TRUE;
  2630. }
  2631. return FALSE;
  2632. }
  2633. BOOL AddSortColumn(DBID const & propSpec,
  2634. BOOL fDirection,
  2635. LCID locale = GetSystemDefaultLCID());
  2636. inline BOOL AddSortColumn( CDbSortKey const & sortkey );
  2637. private:
  2638. CDbSortListAnchor * _FindOrAddAnchor();
  2639. };
  2640. //+---------------------------------------------------------------------------
  2641. //
  2642. // Class: CDbNestingNode
  2643. //
  2644. // Purpose: Wrapper for the DBCOMMANDTREE nesting node.
  2645. //
  2646. // History: 06 Aug 1995 AlanW Created
  2647. //
  2648. // Notes:
  2649. //
  2650. //----------------------------------------------------------------------------
  2651. class CDbNestingNode : public CDbCmdTreeNode
  2652. {
  2653. public:
  2654. CDbNestingNode() : CDbCmdTreeNode( DBOP_nesting ) {}
  2655. BOOL AddTable( CDbCmdTreeNode * pTable );
  2656. BOOL AddGroupingColumn( DBID const & propSpec, LPWSTR pwszName = 0 )
  2657. {
  2658. CDbProjectListAnchor * pAnchor = _FindGroupListAnchor();
  2659. if (pAnchor)
  2660. return pAnchor->AppendListElement( propSpec, pwszName );
  2661. else
  2662. return FALSE;
  2663. }
  2664. BOOL AddParentColumn( DBID const & propSpec )
  2665. {
  2666. CDbProjectListAnchor * pAnchor = _FindParentListAnchor();
  2667. if (pAnchor)
  2668. return pAnchor->AppendListElement( propSpec );
  2669. else
  2670. return FALSE;
  2671. }
  2672. BOOL AddChildColumn( DBID const & propSpec )
  2673. {
  2674. CDbProjectListAnchor * pAnchor = _FindChildListAnchor();
  2675. if (pAnchor)
  2676. return pAnchor->AppendListElement( propSpec );
  2677. else
  2678. return FALSE;
  2679. }
  2680. BOOL SetChildList( CDbProjectListAnchor & propList )
  2681. {
  2682. CDbProjectListAnchor * pAnchor = _FindChildListAnchor();
  2683. if (pAnchor)
  2684. {
  2685. pAnchor->FreeList();
  2686. return pAnchor->SetList( propList.AcquireList() );
  2687. }
  2688. else
  2689. return FALSE;
  2690. }
  2691. private:
  2692. CDbProjectListAnchor * _FindGroupListAnchor();
  2693. CDbProjectListAnchor * _FindParentListAnchor()
  2694. {
  2695. CDbProjectListAnchor * pAnchor = _FindGroupListAnchor();
  2696. if (pAnchor)
  2697. pAnchor = (CDbProjectListAnchor *)pAnchor->GetNextSibling();
  2698. return pAnchor;
  2699. }
  2700. CDbProjectListAnchor * _FindChildListAnchor()
  2701. {
  2702. CDbProjectListAnchor * pAnchor = _FindParentListAnchor();
  2703. if (pAnchor)
  2704. pAnchor = (CDbProjectListAnchor *)pAnchor->GetNextSibling();
  2705. return pAnchor;
  2706. }
  2707. };
  2708. //+---------------------------------------------------------------------------
  2709. //
  2710. // Class: CDbRestriction
  2711. //
  2712. // Purpose:
  2713. //
  2714. // History: 6-07-95 srikants Created
  2715. //
  2716. // Notes:
  2717. //
  2718. //----------------------------------------------------------------------------
  2719. class CDbRestriction : public CDbCmdTreeNode
  2720. {
  2721. public:
  2722. CDbRestriction( DBCOMMANDOP opVal = DBOP_DEFAULT ) : CDbCmdTreeNode( opVal )
  2723. {
  2724. }
  2725. void SetOperator( DBCOMMANDOP opVal )
  2726. {
  2727. op = opVal;
  2728. }
  2729. };
  2730. //+-------------------------------------------------------------------------
  2731. //
  2732. // Class: CDbNodeRestriction
  2733. //
  2734. // Purpose: Boolean AND/OR/VECTOR restriction
  2735. //
  2736. // History: 31-Dec-93 KyleP Created
  2737. //
  2738. //--------------------------------------------------------------------------
  2739. class CDbNodeRestriction : public CDbRestriction
  2740. {
  2741. public:
  2742. //
  2743. // Constructors
  2744. //
  2745. CDbNodeRestriction( DBCOMMANDOP opVal ) : CDbRestriction( opVal ) {}
  2746. //
  2747. // Manipulating the tree.
  2748. //
  2749. void AppendChild( CDbRestriction *pChild ) {
  2750. CDbRestriction::AppendChild( pChild );
  2751. }
  2752. void InsertChild( CDbRestriction *pChild ) {
  2753. CDbRestriction::InsertChild( pChild );
  2754. }
  2755. private:
  2756. };
  2757. //+-------------------------------------------------------------------------
  2758. //
  2759. // Class: CDbBooleanNodeRestriction
  2760. //
  2761. // Purpose: Boolean AND/OR restriction with weights.
  2762. //
  2763. // History: 11-Aug-97 KrishnaN Created
  2764. //
  2765. //--------------------------------------------------------------------------
  2766. class CDbBooleanNodeRestriction : public CDbNodeRestriction
  2767. {
  2768. public:
  2769. //
  2770. // Constructors
  2771. //
  2772. CDbBooleanNodeRestriction( DBCOMMANDOP opVal ) : CDbNodeRestriction( opVal )
  2773. {
  2774. SetValueType(DBVALUEKIND_I4);
  2775. SetWeight(0);
  2776. }
  2777. //
  2778. // Setting and getting weight
  2779. //
  2780. LONG GetWeight() const
  2781. {
  2782. return value.lValue;
  2783. }
  2784. void SetWeight( LONG lWeight )
  2785. {
  2786. value.lValue = lWeight;
  2787. }
  2788. private:
  2789. };
  2790. //+---------------------------------------------------------------------------
  2791. //
  2792. // Class: CDbNotRestriction
  2793. //
  2794. // Purpose:
  2795. //
  2796. // History: 6-07-95 srikants Created
  2797. // 5-08-97 KrishnaN enabled weights
  2798. //
  2799. // Notes:
  2800. //
  2801. //----------------------------------------------------------------------------
  2802. class CDbNotRestriction : public CDbRestriction
  2803. {
  2804. public:
  2805. //
  2806. // Constructors
  2807. //
  2808. CDbNotRestriction() : CDbRestriction( DBOP_not )
  2809. {
  2810. SetValueType(DBVALUEKIND_I4);
  2811. SetWeight(0);
  2812. }
  2813. CDbNotRestriction( CDbRestriction * pres ) : CDbRestriction( DBOP_not )
  2814. {
  2815. SetValueType(DBVALUEKIND_I4);
  2816. SetWeight(0);
  2817. InsertChild( pres );
  2818. }
  2819. //
  2820. // Setting and getting weight
  2821. //
  2822. LONG GetWeight() const
  2823. {
  2824. return value.lValue;
  2825. }
  2826. void SetWeight( LONG lWeight )
  2827. {
  2828. value.lValue = lWeight;
  2829. }
  2830. //
  2831. // Node manipulation
  2832. //
  2833. void SetChild( CDbRestriction * pres )
  2834. {
  2835. delete RemoveFirstChild();
  2836. InsertChild( pres );
  2837. }
  2838. CDbRestriction * GetChild()
  2839. {
  2840. return (CDbRestriction *) GetFirstChild();
  2841. }
  2842. };
  2843. //+---------------------------------------------------------------------------
  2844. //
  2845. // Class: CDbPropBaseRestriction
  2846. //
  2847. // Purpose: Base class for CDbPropertyRestriction and
  2848. // CDbContentBaseRestriction. Provides access to the
  2849. // property child node.
  2850. //
  2851. // History: 26 Jul 1995 AlanW Created
  2852. //
  2853. // Notes:
  2854. //
  2855. //----------------------------------------------------------------------------
  2856. class CDbPropBaseRestriction : public CDbRestriction
  2857. {
  2858. public:
  2859. //
  2860. // Constructors
  2861. //
  2862. CDbPropBaseRestriction( DBCOMMANDOP opVal = DBOP_DEFAULT ) :
  2863. CDbRestriction(opVal) {}
  2864. //
  2865. // Child node access
  2866. //
  2867. BOOL SetProperty( DBID const & Property );
  2868. BOOL SetProperty( CDbColumnNode const & Property );
  2869. CDbColumnNode const * GetProperty() const
  2870. {
  2871. const CDbCmdTreeNode * pChild = GetFirstChild();
  2872. if ( 0 != pChild && pChild->IsColumnName() )
  2873. {
  2874. const CDbColumnNode * pProperty = (CDbColumnNode *) pChild;
  2875. return pProperty;
  2876. }
  2877. return 0;
  2878. }
  2879. BOOL IsValid() const
  2880. {
  2881. CDbColumnNode const * p = GetProperty();
  2882. return( 0 != p && p->IsValid() );
  2883. }
  2884. };
  2885. //+---------------------------------------------------------------------------
  2886. //
  2887. // Class: CDbPropertyRestriction
  2888. //
  2889. // Purpose: Restriction for relational operators, and "like" operator
  2890. //
  2891. // History: 6-07-95 srikants Created
  2892. //
  2893. // Notes:
  2894. //
  2895. //----------------------------------------------------------------------------
  2896. class CDbPropertyRestriction : public CDbPropBaseRestriction
  2897. {
  2898. public:
  2899. //
  2900. // Constructors
  2901. //
  2902. CDbPropertyRestriction() : CDbPropBaseRestriction()
  2903. {
  2904. SetValueType(DBVALUEKIND_I4);
  2905. SetWeight(0);
  2906. }
  2907. CDbPropertyRestriction( DBCOMMANDOP relop,
  2908. DBID const & Property,
  2909. CStorageVariant const & prval );
  2910. CDbPropertyRestriction( DBCOMMANDOP relop,
  2911. CDbColumnNode const & Property,
  2912. CStorageVariant const & prval );
  2913. //
  2914. // Setting and getting weight
  2915. //
  2916. LONG GetWeight() const
  2917. {
  2918. if (DBOP_like == op)
  2919. return GetDbLike()->GetWeight();
  2920. else
  2921. return value.lValue;
  2922. }
  2923. void SetWeight( LONG lWeight )
  2924. {
  2925. if ( DBOP_like == op )
  2926. GetDbLike()->SetWeight(lWeight);
  2927. else
  2928. value.lValue = lWeight;
  2929. }
  2930. //
  2931. // Member variable access
  2932. //
  2933. void SetRelation( DBCOMMANDOP relop )
  2934. {
  2935. // Win4Assert(relop >= DBOP_is_NOT_NULL);
  2936. if ( DBOP_like == relop )
  2937. _SetLikeRelation();
  2938. else
  2939. op = relop;
  2940. }
  2941. DBCOMMANDOP Relation()
  2942. {
  2943. return op;
  2944. }
  2945. BOOL SetValue( double dValue )
  2946. {
  2947. CDbScalarValue * pValue = _FindOrAddValueNode();
  2948. if (pValue) {
  2949. pValue->SetValue( dValue );
  2950. return TRUE;
  2951. }
  2952. else
  2953. return FALSE;
  2954. }
  2955. BOOL SetValue( ULONG ulValue )
  2956. {
  2957. CDbScalarValue * pValue = _FindOrAddValueNode();
  2958. if (pValue) {
  2959. pValue->SetValue( ulValue );
  2960. return TRUE;
  2961. }
  2962. else
  2963. return FALSE;
  2964. }
  2965. BOOL SetValue( LONG lValue )
  2966. {
  2967. CDbScalarValue * pValue = _FindOrAddValueNode();
  2968. if (pValue) {
  2969. pValue->SetValue( lValue );
  2970. return TRUE;
  2971. }
  2972. else
  2973. return FALSE;
  2974. }
  2975. BOOL SetValue( LARGE_INTEGER llValue )
  2976. {
  2977. CDbScalarValue * pValue = _FindOrAddValueNode();
  2978. if (pValue) {
  2979. pValue->SetValue( llValue );
  2980. return TRUE;
  2981. }
  2982. else
  2983. return FALSE;
  2984. }
  2985. BOOL SetValue( FILETIME ftValue )
  2986. {
  2987. CDbScalarValue * pValue = _FindOrAddValueNode();
  2988. if (pValue) {
  2989. pValue->SetValue( ftValue );
  2990. return TRUE;
  2991. }
  2992. else
  2993. return FALSE;
  2994. }
  2995. BOOL SetValue( CY CyValue )
  2996. {
  2997. CDbScalarValue * pValue = _FindOrAddValueNode();
  2998. if (pValue) {
  2999. pValue->SetValue( CyValue );
  3000. return TRUE;
  3001. }
  3002. else
  3003. return FALSE;
  3004. }
  3005. BOOL SetValue( float fValue )
  3006. {
  3007. CDbScalarValue * pValue = _FindOrAddValueNode();
  3008. if (pValue) {
  3009. pValue->SetValue( fValue );
  3010. return TRUE;
  3011. }
  3012. else
  3013. return FALSE;
  3014. }
  3015. BOOL SetValue( SHORT sValue )
  3016. {
  3017. CDbScalarValue * pValue = _FindOrAddValueNode();
  3018. if (pValue) {
  3019. pValue->SetValue( sValue );
  3020. return TRUE;
  3021. }
  3022. else
  3023. return FALSE;
  3024. }
  3025. BOOL SetValue( USHORT usValue )
  3026. {
  3027. CDbScalarValue * pValue = _FindOrAddValueNode();
  3028. if (pValue) {
  3029. pValue->SetValue( usValue );
  3030. return TRUE;
  3031. }
  3032. else
  3033. return FALSE;
  3034. }
  3035. BOOL SetValue( const CStorageVariant &prval )
  3036. {
  3037. CDbScalarValue * pValue = _FindOrAddValueNode();
  3038. if (pValue) {
  3039. pValue->SetValue( prval );
  3040. return TRUE;
  3041. }
  3042. else
  3043. return FALSE;
  3044. }
  3045. BOOL SetDate ( DATE dValue )
  3046. {
  3047. CDbScalarValue * pValue = _FindOrAddValueNode();
  3048. if (pValue) {
  3049. pValue->SetValue( dValue );
  3050. return TRUE;
  3051. }
  3052. else
  3053. return FALSE;
  3054. }
  3055. BOOL SetBOOL( BOOL fValue )
  3056. {
  3057. CDbScalarValue * pValue = _FindOrAddValueNode();
  3058. if (pValue) {
  3059. pValue->SetBOOL( fValue );
  3060. return TRUE;
  3061. }
  3062. else
  3063. return FALSE;
  3064. }
  3065. BOOL SetValue( BLOB & bValue )
  3066. {
  3067. CDbScalarValue * pValue = _FindOrAddValueNode();
  3068. if (pValue) {
  3069. pValue->SetValue( bValue );
  3070. return TRUE;
  3071. }
  3072. else
  3073. return FALSE;
  3074. }
  3075. BOOL SetValue( WCHAR * pwcsValue )
  3076. {
  3077. CDbScalarValue * pValue = _FindOrAddValueNode();
  3078. if (pValue) {
  3079. pValue->SetValue( pwcsValue );
  3080. return TRUE;
  3081. }
  3082. else
  3083. return FALSE;
  3084. }
  3085. BOOL SetValue( GUID * pguidValue)
  3086. {
  3087. CDbScalarValue * pValue = _FindOrAddValueNode();
  3088. if (pValue) {
  3089. pValue->SetValue( pguidValue );
  3090. return TRUE;
  3091. }
  3092. else
  3093. return FALSE;
  3094. }
  3095. BOOL IsValid() const
  3096. {
  3097. if ( DBVALUEKIND_LIKE == GetValueType() && 0 == value.pdblikeValue )
  3098. return FALSE;
  3099. CDbScalarValue const * pValue = _FindConstValueNode();
  3100. return ( ( 0 != pValue ) &&
  3101. ( pValue->IsValid() ) );
  3102. }
  3103. BOOL IsCIDialect();
  3104. protected:
  3105. CDbLike * GetDbLike()
  3106. {
  3107. return (CDbLike *) value.pdblikeValue;
  3108. }
  3109. CDbLike const * GetDbLike() const
  3110. {
  3111. return (CDbLike const *) value.pdblikeValue;
  3112. }
  3113. void _SetLikeRelation()
  3114. {
  3115. SetValueType(DBVALUEKIND_LIKE);
  3116. CDbLike *pTemp = new CDbLike(DBGUID_LIKE_OFS, 0);
  3117. value.pdblikeValue = (DBLIKE *)pTemp;
  3118. op = DBOP_like;
  3119. }
  3120. private:
  3121. void _CleanValue();
  3122. BOOL _IsRelop( DBCOMMANDOP op );
  3123. CDbScalarValue const * _FindConstValueNode() const
  3124. {
  3125. CDbCmdTreeNode const * pCurr = GetFirstChild();
  3126. while ( 0 != pCurr )
  3127. {
  3128. if ( pCurr->IsScalarNode() )
  3129. break;
  3130. pCurr = pCurr->GetNextSibling();
  3131. }
  3132. return (CDbScalarValue const *) pCurr;
  3133. }
  3134. CDbScalarValue * _FindValueNode()
  3135. {
  3136. // override const!
  3137. return (CDbScalarValue *) _FindConstValueNode();
  3138. }
  3139. CDbScalarValue * _FindOrAddValueNode();
  3140. };
  3141. //+---------------------------------------------------------------------------
  3142. //
  3143. // Class: CDbVectorRestriction ()
  3144. //
  3145. // Purpose:
  3146. //
  3147. // History: 6-11-95 srikants Created
  3148. //
  3149. // Notes:
  3150. //
  3151. //----------------------------------------------------------------------------
  3152. class CDbVectorRestriction : public CDbNodeRestriction
  3153. {
  3154. public:
  3155. //
  3156. // Constructors
  3157. //
  3158. CDbVectorRestriction( ULONG ulRankMethod )
  3159. : CDbNodeRestriction( DBOP_content_vector_or )
  3160. {
  3161. SetValueType( DBVALUEKIND_CONTENTVECTOR );
  3162. CDbContentVector * pTemp = new CDbContentVector( ulRankMethod );
  3163. if ( pTemp )
  3164. {
  3165. value.pdbcntntvcValue = pTemp->CastToStruct();
  3166. }
  3167. }
  3168. //
  3169. // Member variable access
  3170. //
  3171. void SetRankMethod( ULONG ulRankMethod )
  3172. {
  3173. CDbContentVector * pVector = GetContentVector();
  3174. pVector->SetRankMethod( ulRankMethod );
  3175. }
  3176. ULONG RankMethod() const
  3177. {
  3178. CDbContentVector const * pVector = GetContentVector();
  3179. return pVector->RankMethod();
  3180. }
  3181. LONG GetWeight() const
  3182. {
  3183. CDbContentVector const * pVector = GetContentVector();
  3184. return pVector->GetWeight();
  3185. }
  3186. void SetWeight( LONG lWeight )
  3187. {
  3188. CDbContentVector * pVector = GetContentVector();
  3189. pVector->SetWeight( lWeight );
  3190. }
  3191. BOOL IsValid() const
  3192. {
  3193. return ( ( 0 != GetContentVector() ) &&
  3194. ( GetContentVector()->IsValid() ) );
  3195. }
  3196. CDbContentVector * GetContentVector()
  3197. {
  3198. return (CDbContentVector *) value.pdbcntntvcValue;
  3199. }
  3200. CDbContentVector const * GetContentVector() const
  3201. {
  3202. return (CDbContentVector const *) value.pdbcntntvcValue;
  3203. }
  3204. private:
  3205. };
  3206. //+---------------------------------------------------------------------------
  3207. //
  3208. // Class: CDbContentBaseRestriction
  3209. //
  3210. // Purpose:
  3211. //
  3212. // History: 6-13-95 srikants Created
  3213. //
  3214. // Notes:
  3215. //
  3216. //----------------------------------------------------------------------------
  3217. class CDbContentBaseRestriction : public CDbPropBaseRestriction
  3218. {
  3219. public:
  3220. BOOL SetPhrase( const WCHAR * pwcsPhrase )
  3221. {
  3222. return GetDbContent()->SetPhrase( pwcsPhrase );
  3223. }
  3224. WCHAR const * GetPhrase() const
  3225. {
  3226. return GetDbContent()->GetPhrase();
  3227. }
  3228. void SetLocale( LCID locale )
  3229. {
  3230. GetDbContent()->SetLocale( locale );
  3231. }
  3232. LCID GetLocale() const
  3233. {
  3234. return GetDbContent()->GetLocale();
  3235. }
  3236. LONG GetWeight() const
  3237. {
  3238. return GetDbContent()->GetWeight();
  3239. }
  3240. void SetWeight( LONG weight )
  3241. {
  3242. GetDbContent()->SetWeight( weight );
  3243. }
  3244. BOOL IsContentValid() const
  3245. {
  3246. CDbContent const * pTemp = GetDbContent();
  3247. return ( ( 0 != pTemp ) && ( pTemp->IsValid() ) );
  3248. }
  3249. BOOL IsValid() const
  3250. {
  3251. return ( IsContentValid() && CDbPropBaseRestriction::IsValid() );
  3252. }
  3253. protected:
  3254. CDbContentBaseRestriction( DBCOMMANDOP opVal,
  3255. DWORD GenerateMethod = GENERATE_METHOD_EXACT,
  3256. ULONG lWeight = 0,
  3257. LCID lcid = 0,
  3258. const WCHAR * pwszPhrase = 0
  3259. ) : CDbPropBaseRestriction( opVal )
  3260. {
  3261. wKind = DBVALUEKIND_CONTENT;
  3262. CDbContent * pTemp = new CDbContent( GenerateMethod, lWeight,
  3263. lcid, pwszPhrase );
  3264. value.pdbcntntValue = (DBCONTENT *) pTemp;
  3265. }
  3266. BOOL _IsContentNode()
  3267. {
  3268. return DBOP_content == op ||
  3269. DBOP_content_proximity == op ||
  3270. DBOP_content_freetext == op ||
  3271. DBOP_content_vector_or == op ;
  3272. }
  3273. void _Cleanup()
  3274. {
  3275. CDbContent * pContent = GetDbContent();
  3276. pContent->Cleanup();
  3277. }
  3278. CDbContent * GetDbContent()
  3279. {
  3280. return (CDbContent *) value.pdbcntntValue;
  3281. }
  3282. CDbContent const * GetDbContent() const
  3283. {
  3284. return (CDbContent const *) value.pdbcntntValue;
  3285. }
  3286. };
  3287. //+-------------------------------------------------------------------------
  3288. //
  3289. // Class: CDbProximityNodeRestriction
  3290. //
  3291. // Purpose: Proximity AND/OR restriction with weights.
  3292. //
  3293. // History: 11-Aug-97 KrishnaN Created
  3294. //
  3295. //--------------------------------------------------------------------------
  3296. class CDbProximityNodeRestriction : public CDbNodeRestriction
  3297. {
  3298. public:
  3299. //
  3300. // Constructors
  3301. //
  3302. CDbProximityNodeRestriction(DWORD dwProximityUnit = PROXIMITY_UNIT_WORD,
  3303. ULONG ulDistance = 50,
  3304. LONG lWeight = 0 )
  3305. : CDbNodeRestriction( DBOP_content_proximity )
  3306. {
  3307. SetValueType(DBVALUEKIND_CONTENTPROXIMITY);
  3308. CDbContentProximity * pTemp = new CDbContentProximity(dwProximityUnit, ulDistance, lWeight);
  3309. value.pdbcntntproxValue = (DBCONTENTPROXIMITY *) pTemp;
  3310. }
  3311. BOOL IsValid() const { return 0 != value.pdbcntntproxValue; }
  3312. //
  3313. // Setting and getting weight
  3314. //
  3315. LONG GetWeight() const
  3316. {
  3317. return GetDbContentProximity()->GetWeight();
  3318. }
  3319. void SetWeight( LONG lWeight )
  3320. {
  3321. GetDbContentProximity()->SetWeight(lWeight);
  3322. }
  3323. //
  3324. // Setting and getting proximity parameters
  3325. //
  3326. DWORD GetProximityUnit() const
  3327. {
  3328. return GetDbContentProximity()->GetProximityUnit();
  3329. }
  3330. void SetProximityUnit(DWORD dwProximityUnit)
  3331. {
  3332. GetDbContentProximity()->SetProximityUnit(dwProximityUnit);
  3333. }
  3334. ULONG GetProximityDistance() const
  3335. {
  3336. return GetDbContentProximity()->GetProximityDistance();
  3337. }
  3338. void SetProximityDistance(ULONG ulDistance)
  3339. {
  3340. GetDbContentProximity()->SetProximityDistance(ulDistance);
  3341. }
  3342. protected:
  3343. CDbContentProximity * GetDbContentProximity()
  3344. {
  3345. return (CDbContentProximity *) value.pdbcntntproxValue;
  3346. }
  3347. CDbContentProximity const * GetDbContentProximity() const
  3348. {
  3349. return (CDbContentProximity const *) value.pdbcntntproxValue;
  3350. }
  3351. };
  3352. //+---------------------------------------------------------------------------
  3353. //
  3354. // Class: CDbNatLangRestriction
  3355. //
  3356. // Purpose:
  3357. //
  3358. // History: 6-11-95 srikants Created
  3359. //
  3360. // Notes:
  3361. //
  3362. //----------------------------------------------------------------------------
  3363. class CDbNatLangRestriction : public CDbContentBaseRestriction
  3364. {
  3365. public:
  3366. CDbNatLangRestriction( const WCHAR * pwcsPhrase,
  3367. CDbColumnNode const & Property,
  3368. LCID lcid = GetSystemDefaultLCID() );
  3369. CDbNatLangRestriction( const WCHAR * pwcsPhrase,
  3370. DBID const & Property,
  3371. LCID lcid = GetSystemDefaultLCID() );
  3372. private:
  3373. };
  3374. //+---------------------------------------------------------------------------
  3375. //
  3376. // Class: CDbContentRestriction
  3377. //
  3378. // Purpose:
  3379. //
  3380. // History: 6-11-95 srikants Created
  3381. //
  3382. // Notes:
  3383. //
  3384. //----------------------------------------------------------------------------
  3385. class CDbContentRestriction : public CDbContentBaseRestriction
  3386. {
  3387. public:
  3388. CDbContentRestriction( const WCHAR * pwcsPhrase,
  3389. CDbColumnNode const & Property,
  3390. ULONG ulGenerateMethod = 0,
  3391. LCID lcid = GetSystemDefaultLCID() );
  3392. CDbContentRestriction( const WCHAR * pwcsPhrase,
  3393. DBID const & Property,
  3394. ULONG ulGenerateMethod = 0,
  3395. LCID lcid = GetSystemDefaultLCID() );
  3396. //
  3397. // Member variable access
  3398. //
  3399. void SetGenerateMethod( ULONG ulFuzzy )
  3400. {
  3401. GetDbContent()->SetGenerateMethod( ulFuzzy );
  3402. }
  3403. ULONG GenerateMethod() const { return GetDbContent()->GetGenerateMethod(); }
  3404. };
  3405. //+-------------------------------------------------------------------------
  3406. //
  3407. // Class: CDTopNode
  3408. //
  3409. // Purpose: Specifies a cap on the number of results
  3410. //
  3411. // History: 2-21-96 SitaramR Created
  3412. //
  3413. //--------------------------------------------------------------------------
  3414. class CDbTopNode : public CDbCmdTreeNode
  3415. {
  3416. public:
  3417. CDbTopNode()
  3418. : CDbCmdTreeNode( DBOP_top, DBVALUEKIND_UI4 )
  3419. {
  3420. }
  3421. void SetChild( CDbCmdTreeNode *pChild )
  3422. {
  3423. AppendChild( pChild );
  3424. }
  3425. CDbCmdTreeNode *GetChild()
  3426. {
  3427. return GetFirstChild();
  3428. }
  3429. void SetValue( ULONG ulValue )
  3430. {
  3431. value.ulValue = ulValue;
  3432. }
  3433. ULONG GetValue()
  3434. {
  3435. return value.ulValue;
  3436. }
  3437. };
  3438. //+-------------------------------------------------------------------------
  3439. //
  3440. // Class: CDbFirstRowsNode
  3441. //
  3442. // Purpose: Specifies the first rows
  3443. //
  3444. // History: 6-28-2000 KitmanH Created
  3445. //
  3446. //--------------------------------------------------------------------------
  3447. class CDbFirstRowsNode : public CDbCmdTreeNode
  3448. {
  3449. public:
  3450. CDbFirstRowsNode()
  3451. : CDbCmdTreeNode( DBOP_firstrows, DBVALUEKIND_UI4 )
  3452. {
  3453. }
  3454. void SetChild( CDbCmdTreeNode *pChild )
  3455. {
  3456. AppendChild( pChild );
  3457. }
  3458. CDbCmdTreeNode *GetChild()
  3459. {
  3460. return GetFirstChild();
  3461. }
  3462. void SetValue( ULONG ulValue )
  3463. {
  3464. value.ulValue = ulValue;
  3465. }
  3466. ULONG GetValue()
  3467. {
  3468. return value.ulValue;
  3469. }
  3470. };
  3471. //+-------------------------------------------------------------------------
  3472. //
  3473. // Class: CDbColumns
  3474. //
  3475. // Purpose: C++ wrapper for array of CDbColId
  3476. //
  3477. // History: 22-Jun-93 KyleP Created
  3478. //
  3479. //--------------------------------------------------------------------------
  3480. class CDbColumns
  3481. {
  3482. public:
  3483. //
  3484. // Constructors
  3485. //
  3486. CDbColumns( unsigned size = 0 );
  3487. //
  3488. // Copy constructors/assignment/clone
  3489. //
  3490. CDbColumns( CDbColumns const & src );
  3491. CDbColumns & operator=( CDbColumns const & src );
  3492. //
  3493. // Destructor
  3494. //
  3495. ~CDbColumns();
  3496. //
  3497. // Memory allocation
  3498. //
  3499. void * operator new( size_t size );
  3500. void operator delete( void * p );
  3501. //
  3502. // Serialization
  3503. //
  3504. void Marshall( PSerStream & stm ) const;
  3505. CDbColumns( PDeSerStream & stm );
  3506. //
  3507. // C/C++ conversion
  3508. //
  3509. inline DBID * GetColumnsArray() const;
  3510. //
  3511. // Member variable access
  3512. //
  3513. BOOL Add( CDbColId const & Property, unsigned pos );
  3514. void Remove( unsigned pos );
  3515. inline CDbColId const & Get( unsigned pos ) const;
  3516. inline unsigned Count() const;
  3517. BOOL IsValid() const
  3518. {
  3519. return _cCol ? 0 != _aCol : TRUE;
  3520. }
  3521. private:
  3522. unsigned _cCol;
  3523. CDbColId * _aCol;
  3524. unsigned _size;
  3525. };
  3526. #if !defined(QUERY_SORTASCEND)
  3527. #define QUERY_SORTASCEND ( 0 )
  3528. #define QUERY_SORTDESCEND ( 1 )
  3529. #endif // !defined(QUERY_SORTASCEND)
  3530. //+-------------------------------------------------------------------------
  3531. //
  3532. // Structure: CDbSortKey
  3533. //
  3534. // Purpose: sort key class, for convenience in building sort lists
  3535. //
  3536. //--------------------------------------------------------------------------
  3537. class CDbSortKey
  3538. {
  3539. public:
  3540. //
  3541. // Constructors
  3542. //
  3543. inline CDbSortKey();
  3544. inline CDbSortKey( CDbSortKey const & sk );
  3545. inline CDbSortKey( CDbColId const & ps, DWORD dwOrder = QUERY_SORTASCEND);
  3546. inline CDbSortKey( CDbColId const & ps, DWORD dwOrder, LCID locale );
  3547. //
  3548. // Member variable access
  3549. //
  3550. inline void SetProperty( CDbColId const & ps );
  3551. inline CDbColId const & GetProperty() const;
  3552. inline DWORD GetOrder() const;
  3553. inline void SetOrder(DWORD dwOrder);
  3554. inline LCID GetLocale() const;
  3555. inline void SetLocale(LCID locale);
  3556. //
  3557. // Serialization
  3558. //
  3559. void Marshall( PSerStream & stm ) const;
  3560. CDbSortKey( PDeSerStream & stm );
  3561. BOOL IsValid() const { return _property.IsValid(); }
  3562. private:
  3563. CDbColId _property;
  3564. DWORD _dwOrder;
  3565. LCID _locale;
  3566. };
  3567. //+-------------------------------------------------------------------------
  3568. //
  3569. // Class: CDbSortSet
  3570. //
  3571. // Purpose: C++ wrapper for array of CDbSortKeys
  3572. //
  3573. // History: 22-Jun-93 KyleP Created
  3574. //
  3575. //--------------------------------------------------------------------------
  3576. class CDbSortSet
  3577. {
  3578. public:
  3579. //
  3580. // Constructors
  3581. //
  3582. CDbSortSet( unsigned size = 0 );
  3583. //
  3584. // Copy constructors/assignment/clone
  3585. //
  3586. CDbSortSet( CDbSortSet const & src );
  3587. CDbSortSet & operator=( CDbSortSet const & src );
  3588. //
  3589. // Destructor
  3590. //
  3591. ~CDbSortSet();
  3592. //
  3593. // Memory allocation
  3594. //
  3595. inline void * operator new( size_t size );
  3596. inline void operator delete( void * p );
  3597. //
  3598. // Serialization
  3599. //
  3600. void Marshall( PSerStream & stm ) const;
  3601. CDbSortSet( PDeSerStream & stm );
  3602. //
  3603. // Member variable access
  3604. //
  3605. BOOL Add( CDbSortKey const &sk, unsigned pos );
  3606. BOOL Add( CDbColId const & Property, ULONG dwOrder, unsigned pos );
  3607. void Remove( unsigned pos );
  3608. inline CDbSortKey const & Get( unsigned pos ) const;
  3609. inline unsigned Count() const;
  3610. private:
  3611. unsigned _csk;
  3612. CDbSortKey * _ask;
  3613. unsigned _size;
  3614. };
  3615. //
  3616. // Inline methods for CDbColumns
  3617. //
  3618. inline CDbColId const & CDbColumns::Get( unsigned pos ) const
  3619. {
  3620. if ( pos < _cCol )
  3621. return( _aCol[pos] );
  3622. else
  3623. return( *(CDbColId *)0 );
  3624. }
  3625. inline void * CDbColumns::operator new( size_t size )
  3626. {
  3627. return CoTaskMemAlloc( size );
  3628. }
  3629. inline void CDbColumns::operator delete( void * p )
  3630. {
  3631. CoTaskMemFree( p );
  3632. }
  3633. inline unsigned CDbColumns::Count() const
  3634. {
  3635. return( _cCol );
  3636. }
  3637. inline DBID * CDbColumns::GetColumnsArray() const
  3638. {
  3639. return _aCol;
  3640. }
  3641. //
  3642. // Inline methods for CDbSortKey
  3643. //
  3644. inline CDbSortKey::CDbSortKey()
  3645. {
  3646. }
  3647. inline CDbSortKey::CDbSortKey( CDbSortKey const & sk )
  3648. : _property( sk._property ),
  3649. _dwOrder( sk._dwOrder ),
  3650. _locale( sk._locale )
  3651. {
  3652. }
  3653. inline CDbSortKey::CDbSortKey( CDbColId const & ps, ULONG dwOrder )
  3654. : _property( ps ),
  3655. _dwOrder( dwOrder ),
  3656. _locale( 0 )
  3657. {
  3658. }
  3659. inline CDbSortKey::CDbSortKey( CDbColId const & ps, ULONG dwOrder, LCID locale )
  3660. : _property( ps ),
  3661. _dwOrder( dwOrder ),
  3662. _locale ( locale )
  3663. {
  3664. }
  3665. inline void CDbSortKey::SetProperty( CDbColId const & ps )
  3666. {
  3667. _property = ps;
  3668. }
  3669. inline void CDbSortKey::SetLocale( LCID locale )
  3670. {
  3671. _locale = locale;
  3672. }
  3673. inline void CDbSortKey::SetOrder( DWORD dwOrder )
  3674. {
  3675. _dwOrder = dwOrder;
  3676. }
  3677. inline CDbColId const & CDbSortKey::GetProperty() const
  3678. {
  3679. return _property;
  3680. }
  3681. inline LCID CDbSortKey::GetLocale() const
  3682. {
  3683. return _locale;
  3684. }
  3685. inline DWORD CDbSortKey::GetOrder() const
  3686. {
  3687. return _dwOrder;
  3688. }
  3689. //
  3690. // Inline methods of CDbSortSet
  3691. //
  3692. inline void * CDbSortSet::operator new( size_t size )
  3693. {
  3694. return CoTaskMemAlloc( size );
  3695. }
  3696. inline void CDbSortSet::operator delete( void * p )
  3697. {
  3698. CoTaskMemFree( p );
  3699. }
  3700. inline CDbSortKey const & CDbSortSet::Get( unsigned pos ) const
  3701. {
  3702. if ( pos < _csk )
  3703. return( _ask[pos] );
  3704. else
  3705. {
  3706. #if DBG == 1
  3707. DebugBreak();
  3708. #endif
  3709. return( *(CDbSortKey *)0 );
  3710. }
  3711. }
  3712. inline unsigned
  3713. CDbSortSet::Count() const
  3714. {
  3715. return _csk;
  3716. }
  3717. //
  3718. // Inline methods of CDbSortNode (needs defn. of CDbSortKey)
  3719. //
  3720. inline BOOL
  3721. CDbSortNode::AddSortColumn( CDbSortKey const & sortkey )
  3722. {
  3723. return AddSortColumn( sortkey.GetProperty(),
  3724. sortkey.GetOrder() == QUERY_SORTDESCEND,
  3725. sortkey.GetLocale() );
  3726. }
  3727. inline BOOL
  3728. CDbSortListAnchor::AppendList( CDbSortListElement* pListElement )
  3729. {
  3730. return CDbListAnchor::AppendList( pListElement );
  3731. }
  3732. inline BOOL
  3733. CDbSortListAnchor::AppendListElement( CDbSortListElement* pListElement )
  3734. {
  3735. return CDbListAnchor::AppendListElement( pListElement );
  3736. }
  3737. #include <poppack.h>
  3738. #endif // __DBCMDTRE_HXX__