home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 May / PCFMay2001.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / _dbdao.h next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  21.4 KB  |  736 lines

  1. /************************************************************************
  2. **    _ D B D A O . H                                                    *
  3. **                                                                        *
  4. *************************************************************************
  5. ** Copyright (C) 1996 - 1999 Microsoft Corporation                     *
  6. **           All Rights Reserved                                             *
  7. ************************************************************************/
  8. /*
  9.     _DBDAO.H
  10.  
  11.     Internal definitions and prototypes for dbdao C++ classes
  12. */
  13. #ifndef __DBDAO_H_
  14. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  15. #define __DBDAO_H_
  16.  
  17.  
  18. /*****************************************************************************
  19. * Forwards
  20. */
  21. class COleVariant;
  22. class CdbBookmark;
  23. class CdbException;
  24. class CdbOleObject;
  25. class CdbObject;
  26. class CdbError;
  27. class CdbProperty;
  28. class CdbDBEngine;
  29. class CdbWorkspace;
  30. class CdbDatabase;
  31. class CdbConnection;
  32. class CdbRecordset;
  33. class CdbGetRowsEx;
  34. class CdbQueryDef;
  35. class CdbTableDef;
  36. class CdbField;
  37. class CdbRelation;
  38. class CdbIndex;
  39. class CdbUser;
  40. class CdbGroup;
  41. class CdbDocument;
  42. class CdbContainer;
  43. class CdbParameter;
  44. class CdbCollection;
  45. class CdbErrors;
  46. class CdbProperties;
  47. class CdbWorkspaces;
  48. class CdbDatabases;
  49. class CdbConnections;
  50. class CdbRecordsets;
  51. class CdbQueryDefs;
  52. class CdbTableDefs;
  53. class CdbFields;
  54. class CdbRelations;
  55. class CdbIndexes;
  56. class CdbUsers;
  57. class CdbGroups;
  58. class CdbDocuments;
  59. class CdbContainers;
  60. class CdbParameters;
  61. class CdbBStr;
  62.  
  63. /*****************************************************************************
  64. * DAO runtime key
  65. */
  66. const char szKEY[] = "mbmabptebkjcdlgtjmskjwtsdhjbmkmwtrak";
  67.  
  68. /*****************************************************************************
  69. * Miscellaneous defines
  70. */
  71. #define DAO_MAXSEEKFIELDS 13
  72.  
  73.  
  74. /*****************************************************************************
  75. * CdbBSTR (OLE BSTR helper)
  76. */
  77. class DLLEXPORT CdbBSTR
  78.     {
  79.     public:
  80.     CONSTRUCTOR            CdbBSTR                (BSTR=NULL);
  81.     DESTRUCTOR            ~CdbBSTR            (VOID);
  82.  
  83.     operator            BSTR *                (VOID);
  84.     operator            LPCTSTR                (VOID);
  85.  
  86.     private:
  87.     BSTR                m_bstr;
  88.     };
  89.  
  90. /*****************************************************************************
  91. * CdbVariant (OLE Variant helper)
  92. */
  93. class CdbVariant : public COleVariant
  94.     {
  95.     public:
  96.     CONSTRUCTOR                        CdbVariant                        (LONG l);
  97.     CONSTRUCTOR                     CdbVariant                      (VOID);
  98.     CONSTRUCTOR                     CdbVariant                      (LPCTSTR pstr);
  99.     CONSTRUCTOR                     CdbVariant                      (SHORT s, BOOL bIsBool = FALSE);
  100.     CONSTRUCTOR                     CdbVariant                      (LPVARIANT pv);
  101.     CONSTRUCTOR                     CdbVariant                      (LPSAFEARRAY psa);
  102.  
  103.     VOID                            operator =                      (LPVARIANT pv);
  104.     VOID                            operator =                      (LPCTSTR pstr);
  105.     VOID                            operator =                      (SHORT s);
  106.     VOID                            operator =                      (const int i);
  107.     VOID                            operator =                      (LONG l);
  108.     };
  109.  
  110. inline CONSTRUCTOR    CdbVariant::CdbVariant(
  111.     VOID) : COleVariant()
  112.     {
  113.     vt        = VT_ERROR;
  114.     scode    = DISP_E_PARAMNOTFOUND;
  115.     }
  116.  
  117. inline CdbVariant::CdbVariant (LONG l)
  118. {
  119.         if (l == -1)        
  120.             {    
  121.             vt        = VT_ERROR;
  122.             scode    = DISP_E_PARAMNOTFOUND;
  123.             }
  124.         else
  125.             {
  126.             vt        = VT_I4;
  127.             lVal    = l;
  128.             }
  129. }
  130.  
  131.  
  132. inline CONSTRUCTOR    CdbVariant::CdbVariant(
  133.     LPCTSTR pstr): COleVariant(pstr,VT_BSTRT)
  134.     {
  135.     if (!pstr)
  136.         {
  137.         VariantClear(this);
  138.         vt        = VT_ERROR;
  139.         scode    = DISP_E_PARAMNOTFOUND;
  140.         }
  141.     }
  142.  
  143.  
  144. inline CONSTRUCTOR    CdbVariant::CdbVariant(
  145.     SHORT s, BOOL bIsBool) : COleVariant(s)
  146.     {
  147.     if (bIsBool)
  148.         {
  149.         vt        = VT_BOOL;
  150.         boolVal    = s;
  151.         }
  152.     else if (s==-1)
  153.         {
  154.         vt        = VT_ERROR;
  155.         scode    = DISP_E_PARAMNOTFOUND;
  156.         }
  157.     }
  158.  
  159. inline CONSTRUCTOR    CdbVariant::CdbVariant(
  160.     LPVARIANT    pv)
  161.     {
  162.     if (!pv)
  163.         {
  164.         vt        = VT_ERROR;
  165.         scode    = DISP_E_PARAMNOTFOUND;
  166.         }
  167.     else
  168.         VariantCopy(this, pv);
  169.     }
  170.  
  171. inline CONSTRUCTOR    CdbVariant::CdbVariant(
  172.     LPSAFEARRAY psa)
  173.     {
  174.     if (!psa)
  175.         {
  176.         vt        = VT_ERROR;
  177.         scode    = DISP_E_PARAMNOTFOUND;
  178.         }
  179.     else
  180.         {
  181.         vt        = VT_ARRAY|VT_UI1;
  182.         parray    = psa;
  183.         }
  184.     }
  185.  
  186. inline VOID    CdbVariant::operator =(
  187.     LPVARIANT pv)
  188.     {
  189.     if (!pv)
  190.         {
  191.         vt        = VT_ERROR;
  192.         scode    = DISP_E_PARAMNOTFOUND;
  193.         }
  194.     else
  195.         VariantCopy(this, pv);
  196.     }
  197.  
  198. inline VOID    CdbVariant::operator =(
  199.     LPCTSTR pstr) 
  200.     {
  201.     if (!pstr)
  202.         {
  203.         VariantClear(this);
  204.         vt        = VT_ERROR;
  205.         scode    = DISP_E_PARAMNOTFOUND;
  206.         }
  207.     else
  208.         {
  209. #ifdef UNICODE
  210.         bstrVal = SysAllocString(pstr);
  211. #else
  212.         bstrVal = SysAllocStringByteLen(pstr, strlen(pstr));
  213. #endif
  214.         vt = VT_BSTR;
  215.         }
  216.     }
  217.  
  218.  
  219. inline VOID    CdbVariant::operator =(
  220.     SHORT s)
  221.     {
  222.     if (s==-1)
  223.         {
  224.         vt        = VT_ERROR;
  225.         scode    = DISP_E_PARAMNOTFOUND;
  226.         }
  227.     else
  228.         {
  229.         vt        = VT_I2;
  230.         iVal    = s;
  231.         }
  232.     }
  233.  
  234. inline VOID    CdbVariant::operator =(
  235.     const int i)
  236.     {
  237.     if (i==-1)
  238.         {
  239.         vt        = VT_ERROR;
  240.         scode    = DISP_E_PARAMNOTFOUND;
  241.         }
  242.     else
  243.         {
  244.         vt        = VT_I2;
  245.         iVal    = (SHORT)i;
  246.         }
  247.     }
  248.  
  249.  
  250. inline VOID    CdbVariant::operator =(
  251.     LONG     l)
  252.     {
  253.     if (l==-1)
  254.         {
  255.         vt         = VT_ERROR;
  256.         scode    = DISP_E_PARAMNOTFOUND;
  257.         }
  258.     else
  259.         {
  260.         vt        = VT_I4;
  261.         lVal    = l;
  262.         }
  263.     }
  264.  
  265.  
  266. /*****************************************************************************
  267. * CdbWide
  268. */
  269. HRESULT    CdbWideFromAnsi(LPSTR, unsigned int, BSTR *);
  270.  
  271. class CdbWide
  272.     {
  273.     public:
  274.     CONSTRUCTOR            CdbWide                (LPSTR pstr, unsigned int cb=0)
  275.         {
  276.         CdbWideFromAnsi(pstr, (pstr ? (cb==0 ? strlen(pstr) : cb) : 0), &m_bstr);
  277.         }
  278.     DESTRUCTOR            ~CdbWide            ()
  279.         {
  280.         SysFreeString(m_bstr);
  281.         }
  282.  
  283.     operator            LPWSTR                    ()
  284.         {
  285.         return (LPWSTR)m_bstr;
  286.         }
  287.     operator            LPSTR                    ()
  288.         {
  289.         return (LPSTR)m_bstr;
  290.         }
  291.  
  292.     ULONG                cBytes                    ()
  293.         {
  294.         return SysStringByteLen(m_bstr);
  295.         }
  296.  
  297.     private:
  298.     BSTR                m_bstr;
  299.     };
  300.  
  301.  
  302. /*****************************************************************************
  303. * CdbOleObject
  304. */
  305. class DLLEXPORT CdbOleObject : public CObject
  306.     {
  307.     public:
  308.     CONSTRUCTOR                             CdbOleObject            (VOID);
  309.     virtual DESTRUCTOR                        ~CdbOleObject           (VOID);
  310.     BOOL                                    Exists                  (VOID);
  311.     CdbOleObject &                            operator =              (CdbOleObject &o);
  312.                                             operator LPUNKNOWN        (){ return GetInterface();}
  313.     VOID                                    SetInterface            (LPUNKNOWN punk, BOOL bAddRef=FALSE);
  314.     VOID                                    SetInterface            (REFIID riidClass, REFIID riidInterface);
  315.     VOID                                    SetInterfaceLic         (REFIID riidClass, REFIID riidInterface);
  316.     LPUNKNOWN                                GetInterface            (BOOL bAddRef=FALSE, BOOL bThrowException=TRUE) const;
  317.  
  318.     virtual VOID                            OnInterfaceChange       (VOID);
  319.     VOID                                    SetRichErrorInfo        (LPOLESTR pstrSource, LPOLESTR pstrDescription, LPOLESTR pstrHelpFile, ULONG ulHelpID) const;
  320.  
  321.     protected:
  322.     BOOL                                    StartOLE                        (VOID);
  323.     LPUNKNOWN                               m_punkInterface;
  324.     };
  325.  
  326.  
  327.  
  328. /*****************************************************************************
  329. * CdbCollection
  330. */
  331. class DLLEXPORT CdbCollection : public CdbOleObject
  332.     {
  333.     public:
  334.  
  335.     // Methods
  336.     virtual CdbObject               ObItem                  (LONG i) = 0;
  337.     virtual CdbObject               ObItem                  (LPCTSTR pstr) = 0;
  338.     virtual LONG                    GetCount                (VOID) = 0;
  339.     virtual VOID                    ObAppend                (CdbObject &obj) = 0;
  340.     virtual VOID                    Delete                  (LPCTSTR pstr) = 0;
  341.     virtual VOID                    Refresh                 (VOID) = 0;
  342.     };
  343.  
  344. class DLLEXPORT CdbStaticCollection : public CdbCollection
  345.     {
  346.     public:
  347.     CdbObject                               ObItem                  (LONG i);
  348.     CdbObject                               ObItem                  (LPCTSTR pstr);
  349.     LONG                                    GetCount                (VOID);
  350.     VOID                                    ObAppend                (CdbObject &obj);
  351.     VOID                                    Delete                  (LPCTSTR pstr);
  352.     VOID                                    Refresh                 (VOID) ;
  353.     };
  354.  
  355. class DLLEXPORT CdbDynamicCollection : public CdbCollection
  356.     {
  357.     public:
  358.     CdbObject                               ObItem                  (LONG i);
  359.     CdbObject                               ObItem                  (LPCTSTR pstr);
  360.     LONG                                    GetCount                (VOID);
  361.     VOID                                    ObAppend                (CdbObject &obj);
  362.     VOID                                    Delete                  (LPCTSTR pstr);
  363.     VOID                                    Refresh                 (VOID);
  364.     };
  365.  
  366. #define DAOMFC_STATIC_COLLECTION_DECL(objColl, objSingle, intSingle)    \
  367.     class DLLEXPORT objColl : public CdbStaticCollection                                                    \
  368.         {                                                                                                                               \
  369.         public:                                                                                                                 \
  370.                                                                         \
  371.         objSingle                       Item                            (LONG i);                               \
  372.         objSingle                       Item                            (LPCTSTR pstr);                 \
  373.         objSingle                       operator[]                      (LONG i);                               \
  374.         objSingle                       operator[]                      (LPCTSTR pstr);                 \
  375.         }
  376.  
  377. #define DAOMFC_DYNAMIC_COLLECTION_DECL(objColl, objSingle, intSingle)   \
  378.     class DLLEXPORT objColl : public CdbDynamicCollection                                                   \
  379.         {                                                                                                                               \
  380.         public:                                                                                                                 \
  381.                                                                         \
  382.         objSingle                       Item                            (LONG i);                               \
  383.         objSingle                       Item                            (LPCTSTR pstr);                 \
  384.         VOID                            Append                          (objSingle &o);                 \
  385.         objSingle                       operator[]                      (LONG i);                               \
  386.         objSingle                       operator[]                      (LPCTSTR pstr);                 \
  387.         }
  388.  
  389. DAOMFC_STATIC_COLLECTION_DECL(CdbErrors, CdbError, DAOError);
  390. DAOMFC_STATIC_COLLECTION_DECL(CdbDatabases, CdbDatabase, DAODatabase);
  391. //Connections are special cased so we can trap the copy constructor
  392. DAOMFC_STATIC_COLLECTION_DECL(CdbRecordsets, CdbRecordset, DAORecordset);
  393. DAOMFC_STATIC_COLLECTION_DECL(CdbParameters, CdbParameter, DAOParameter);
  394. DAOMFC_STATIC_COLLECTION_DECL(CdbDocuments, CdbDocument, DAODocument);
  395. DAOMFC_STATIC_COLLECTION_DECL(CdbContainers, CdbContainer, DAOContainer);
  396.  
  397. DAOMFC_DYNAMIC_COLLECTION_DECL(CdbProperties, CdbProperty, DAOProperty);
  398. DAOMFC_DYNAMIC_COLLECTION_DECL(CdbFields, CdbField, DAOField);
  399. DAOMFC_DYNAMIC_COLLECTION_DECL(CdbQueryDefs, CdbQueryDef, DAOQueryDef);
  400. DAOMFC_DYNAMIC_COLLECTION_DECL(CdbTableDefs, CdbTableDef, DAOTableDef);
  401. DAOMFC_DYNAMIC_COLLECTION_DECL(CdbIndexes, CdbIndex, DAOIndex);
  402. DAOMFC_DYNAMIC_COLLECTION_DECL(CdbRelations, CdbRelation, DAORelation);
  403. DAOMFC_DYNAMIC_COLLECTION_DECL(CdbUsers, CdbUser, DAOUser);
  404. DAOMFC_DYNAMIC_COLLECTION_DECL(CdbGroups, CdbGroup, DAOGroup);
  405.  
  406. //Need some extra functions in CdbWorkspaces to support the delay in creating the 
  407. //default workspace needed to support the JET/ODBC option.
  408. class DLLEXPORT CdbWorkspaces : public CdbDynamicCollection
  409.     {        
  410.     friend CdbDBEngine;
  411.     private:
  412.     DAODBEngine    *                    pDBEng;
  413.     BOOL                            m_bDontStart;
  414.  
  415.     public:                                                                                                                 
  416.     CONSTRUCTOR                     CdbWorkspaces            (VOID){pDBEng = NULL;}
  417.     CdbWorkspace                    Item                    (LONG i);                               
  418.     CdbWorkspace                    Item                    (LPCTSTR pstr);                 
  419.     VOID                            Append                  (CdbWorkspace &o);                 
  420.     CdbWorkspace                    operator[]              (LONG i);                         
  421.     CdbWorkspace                    operator[]              (LPCTSTR pstr);                
  422.     VOID                            SetDBEngine                (DAODBEngine    *peng){pDBEng = peng;}
  423.     VOID                            GetDelayedInterface     ();
  424.     };
  425.  
  426. //Need to trap Connections in the copy constructor so the user can't
  427. //get a "sorta-kinda" working Connections collection on a Jet workspace
  428. class DLLEXPORT CdbConnections : public CdbStaticCollection
  429.     {        
  430.     public:
  431.     CONSTRUCTOR                        CdbConnections            (CdbConnections &Connections);
  432.     CONSTRUCTOR                        CdbConnections            (){pwrk = NULL;}
  433.     CdbConnection                   Item                    (LONG i);                               
  434.     CdbConnection                   Item                    (LPCTSTR pstr);                 
  435.     CdbConnection                   operator[]              (LONG i);                               
  436.     CdbConnection                   operator[]              (LPCTSTR pstr);               
  437.     CdbConnections    &                operator =                (CdbConnections &o);
  438.     LONG                            GetCount                (VOID);
  439.     VOID                            Refresh                 (VOID) ;
  440.     VOID                            SetWorkspace            (DAOWorkspace * pParent){pwrk = pParent;}            
  441.  
  442.     private:
  443.     VOID                            CheckInterface();
  444.     DAOWorkspace *                    pwrk;
  445.     };
  446.  
  447. /*****************************************************************************
  448. * CdbObject
  449. */
  450. class DLLEXPORT CdbObject : public CdbOleObject
  451.     {
  452.     public:
  453.     CONSTRUCTOR                             CdbObject                       (VOID);
  454.     CONSTRUCTOR                             CdbObject                       (LPUNKNOWN punk, BOOL bAddRef=FALSE);
  455.  
  456.     virtual CString                 GetName                         (VOID); 
  457.     virtual VOID                    SetName                         (LPCTSTR pstr);
  458.  
  459.     CdbProperties                   Properties;
  460.     };
  461.  
  462.  
  463.  
  464. /*****************************************************************************
  465. * CdbGetRowsEx  (holds GetRowsEx for Recordset)
  466. */
  467.  
  468. class DLLEXPORT CdbGetRowsEx : public CdbObject
  469.     {
  470.     public:
  471.  
  472.     // Administration
  473.     CONSTRUCTOR                     CdbGetRowsEx            (VOID);
  474.     CONSTRUCTOR                     CdbGetRowsEx            (ICDAORecordset *pGetRows, BOOL bAddRef=FALSE);
  475.     CONSTRUCTOR                     CdbGetRowsEx            (const CdbGetRowsEx &);
  476.     CdbGetRowsEx &          operator =                      (const CdbGetRowsEx &);
  477.     VOID                            OnInterfaceChange       (VOID);
  478.  
  479.     };
  480.  
  481. /*****************************************************************************
  482. * Helper macros
  483. */
  484.  
  485. //Initialize a variant
  486. #define DAOVINIT(var)                        \
  487.     do                                        \
  488.         {                                    \
  489.         (var).vt    = VT_ERROR;                \
  490.         (var).scode    = DISP_E_PARAMNOTFOUND;    \
  491.         }                                    \
  492.     while (0)
  493.  
  494.  
  495. // LPTSTR to VARIANT
  496. #define STV(pstr)    CdbVariant(pstr)
  497.  
  498. // LPTSTR to BSTR
  499. #define STB(pstr)    V_BSTR(((LPVARIANT)STV(pstr)))
  500.  
  501. // LONG to VARIANT
  502. #define LTV(l)        CdbVariant(l)
  503.  
  504. // Optional LONG to VARIANT
  505. #define OLTV(l)        CdbVariant((l))
  506.  
  507. // C/C++ bool to DAO bool
  508. #define BTB(b)        ((VARIANT_BOOL)(b?-1:0))
  509.  
  510. // C/C++ bool to VARIANT
  511. #define BTV(b)        CdbVariant(BTB(b), TRUE)
  512.  
  513. // C/C++ short to VARIANT
  514. #define SHTV(s)        CdbVariant((SHORT)s)
  515.  
  516. // OLE variant to VARIANT
  517. #define VTV(pv)        CdbVariant(pv)
  518.  
  519. // SAFEARRAY to VARIANT
  520. #define ATV(psa, var)                                \
  521.     do                                                \
  522.         {                                            \
  523.         if (!psa)                                    \
  524.             {                                        \
  525.             var.vt        = VT_ERROR;                    \
  526.             var.scode    = DISP_E_PARAMNOTFOUND;        \
  527.             }                                        \
  528.         else                                        \
  529.             {                                        \
  530.             var.vt        = VT_ARRAY|VT_UI1;            \
  531.             SafeArrayCopy(psa, &var.parray);    \
  532.             }                                        \
  533.         }                                            \
  534.     while (0)
  535.  
  536. #define DAOMFC_CALL(hr)                        \
  537.     do \
  538.     { \
  539.     HRESULT  hresult = (hr);           \
  540.         if(FAILED(hresult)) \
  541.         { \
  542.             TRACE0("\nDBDAO Call Failed.\n\t"); \
  543.             TRACE2("\nIn file %s on line %d\n", _T("DBDAO.CPP"), __LINE__); \
  544.             TRACE1("hResult = %X\n", hresult); \
  545.             if (GetScode(hresult) == E_OUTOFMEMORY) \
  546.                 AfxThrowMemoryException(); \
  547.             else \
  548.                 throw CdbException(hresult); \
  549.         } \
  550.     } while (0)
  551.  
  552.  
  553. /*****************************************************************************
  554. * Property Set/Get helper macros
  555. */
  556.  
  557. // Get a LONG property
  558. #define LPROPGET(intDAO, meth)                        \
  559.     do                                                \
  560.         {                                            \
  561.         intDAO *    p    = (intDAO *)GetInterface();    \
  562.         LONG        l    = 0;                        \
  563.                                                     \
  564.         DAOMFC_CALL(p->meth(&l));                    \
  565.                                                     \
  566.         return l;                                    \
  567.         }                                            \
  568.     while (0)
  569.  
  570. // Set a LONG property
  571. #define LPROPSET(intDAO, meth, l)                    \
  572.     do                                                \
  573.         {                                            \
  574.         intDAO *    p = (intDAO *)GetInterface();    \
  575.                                                     \
  576.         DAOMFC_CALL(p->meth(l));                    \
  577.         }                                            \
  578.     while(0)
  579.  
  580. // Get a SHORT property
  581. #define WPROPGET(intDAO, meth)                        \
  582.     do                                                \
  583.         {                                            \
  584.         intDAO *    p    = (intDAO *)GetInterface();    \
  585.         SHORT        s    = 0;                        \
  586.                                                     \
  587.         DAOMFC_CALL(p->meth(&s));                    \
  588.                                                     \
  589.         return s;                                    \
  590.         }                                            \
  591.     while (0)
  592.  
  593. // Set a SHORT property
  594. #define WPROPSET(intDAO, meth, s)                    \
  595.     do                                                \
  596.         {                                            \
  597.         intDAO *    p = (intDAO *)GetInterface();    \
  598.                                                     \
  599.         DAOMFC_CALL(p->meth(s));                    \
  600.         }                                            \
  601.     while(0)
  602.  
  603. // Get a STRING property
  604. #define SPROPGET(intDAO, meth)                        \
  605.     do                                                \
  606.         {                                            \
  607.         intDAO *    p    = (intDAO *)GetInterface();    \
  608.         CdbBSTR        bstr;                            \
  609.                                                     \
  610.         DAOMFC_CALL(p->meth(bstr));                    \
  611.                                                     \
  612.         return bstr;                                \
  613.         }                                            \
  614.     while (0)
  615.  
  616. // Set a STRING property
  617. #define SPROPSET(intDAO, meth, s)                    \
  618.     do                                                \
  619.         {                                            \
  620.         intDAO *    p = (intDAO *)GetInterface();    \
  621.                                                     \
  622.         DAOMFC_CALL(p->meth(STB(s)));                \
  623.         }                                            \
  624.     while(0)
  625.  
  626. // Get a DATETIME property
  627. #define DPROPGET(intDAO, meth)                        \
  628.     do                                                \
  629.         {                                            \
  630.         intDAO *    p    = (intDAO *)GetInterface();    \
  631.         VARIANT     Var;                                \
  632.                                                     \
  633.         VariantInit(&Var);                            \
  634.         DAOMFC_CALL(p->meth(&Var));                    \
  635.         return Var;                                    \
  636.         }                                            \
  637.     while (0)
  638.  
  639. // Set a DATETIME property
  640. #define DPROPSET(intDAO, meth, pv)                    \
  641.     do                                                \
  642.         {                                            \
  643.         intDAO *    p = (intDAO *)GetInterface();    \
  644.                                                     \
  645.         DAOMFC_CALL(p->meth(*pv));                    \
  646.         }                                            \
  647.     while(0)
  648.  
  649. // Get a BOOLEAN property
  650. #define BPROPGET(intDAO, meth)                            \
  651.     do                                                    \
  652.         {                                                \
  653.         intDAO *        p    = (intDAO *)GetInterface();    \
  654.         VARIANT_BOOL    vb    = 0;                        \
  655.                                                         \
  656.         DAOMFC_CALL(p->meth(&vb));                        \
  657.                                                         \
  658.         return (BOOL)vb;                                \
  659.         }                                                \
  660.     while (0)
  661.  
  662. // Set a BOOLEAN property
  663. #define BPROPSET(intDAO, meth, b)                        \
  664.     do                                                    \
  665.         {                                                \
  666.         intDAO *    p = (intDAO *)GetInterface();        \
  667.                                                         \
  668.         DAOMFC_CALL(p->meth(BTB(b)));                    \
  669.         }                                                \
  670.     while(0)
  671.  
  672. // Get a VARIANT property
  673. #define VPROPGET(intDAO, meth)                        \
  674.     do                                                \
  675.         {                                            \
  676.         intDAO *    p    = (intDAO *)GetInterface();    \
  677.         COleVariant     v;                                \
  678.                                                     \
  679.         VariantInit(&v);                            \
  680.         DAOMFC_CALL(p->meth(&v));                    \
  681.                                                     \
  682.         return &v;                                    \
  683.         }                                            \
  684.     while (0)
  685.  
  686. // Set a VARIANT property
  687. #define VPROPSET(intDAO, meth, pv)                    \
  688.     do                                                \
  689.         {                                            \
  690.         intDAO *    p = (intDAO *)GetInterface();    \
  691.                                                     \
  692.         DAOMFC_CALL(p->meth(*pv));                    \
  693.         }                                            \
  694.     while(0)
  695.  
  696. // Get a DWORD property
  697. #define DWPROPGET(intDAO, meth)                        \
  698.     do                                                \
  699.         {                                            \
  700.         intDAO *    p    = (intDAO *)GetInterface();    \
  701.         DWORD        dw    = 0;                        \
  702.                                                     \
  703.         DAOMFC_CALL(p->meth(&dw));                    \
  704.                                                     \
  705.         return dw;                                    \
  706.         }                                            \
  707.     while (0)
  708.  
  709.  
  710. #define DAOMFC_STATIC_COLLECTION_IMPL(objColl, objSingle, intColl, intSingle)                                                     \
  711.         objSingle            objColl::Item                (LONG i)         { return (intSingle *)(ObItem(i).GetInterface(TRUE)); }     \
  712.         objSingle            objColl::Item                (LPCTSTR pstr)    { return (intSingle *)(ObItem(pstr).GetInterface(TRUE)); } \
  713.         objSingle            objColl::operator[]            (LONG i)        { return (intSingle *)(Item(i).GetInterface(TRUE)); } \
  714.         objSingle            objColl::operator[]            (LPCTSTR pstr)    { return (intSingle *)(Item(pstr).GetInterface(TRUE)); }
  715.  
  716. #define DAOMFC_DYNAMIC_COLLECTION_IMPL(objColl, objSingle, intColl, intSingle)                                                     \
  717.         objSingle            objColl::Item                (LONG i)         { return (intSingle *)(ObItem(i).GetInterface(TRUE)); }     \
  718.         objSingle            objColl::Item                (LPCTSTR pstr)    { return (intSingle *)(ObItem(pstr).GetInterface(TRUE)); } \
  719.         VOID                objColl::Append                (objSingle &o)    { ObAppend(o); } \
  720.         objSingle            objColl::operator[]            (LONG i)        { return (intSingle *)(Item(i).GetInterface(TRUE)); } \
  721.         objSingle            objColl::operator[]            (LPCTSTR pstr)    { return (intSingle *)(Item(pstr).GetInterface(TRUE)); }
  722.  
  723. DECLARE_INTERFACE_(DAOMFCSCollection, _DAOCollection)
  724. {
  725. STDMETHOD(get_Item)        (VARIANT index, LPUNKNOWN *ppunk);
  726. };
  727.  
  728. DECLARE_INTERFACE_(DAOMFCDCollection, _DAODynaCollection)
  729. {
  730. STDMETHOD(get_Item)        (VARIANT index, LPUNKNOWN *ppunk);
  731. };
  732.  
  733.  
  734. #pragma option pop /*P_O_Pop*/
  735. #endif // __DBDAO_H_ 
  736.