source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/_dbdao.h@ 1194

Last change on this file since 1194 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 14.1 KB
Line 
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#ifndef __DBDAO_H_
7#define __DBDAO_H_
8
9#ifndef __cplusplus
10#error This file can be used only in C++
11#else
12
13class COleVariant;
14class CdbBookmark;
15class CdbException;
16class CdbOleObject;
17class CdbObject;
18class CdbError;
19class CdbProperty;
20class CdbDBEngine;
21class CdbWorkspace;
22class CdbDatabase;
23class CdbConnection;
24class CdbRecordset;
25class CdbGetRowsEx;
26class CdbQueryDef;
27class CdbTableDef;
28class CdbField;
29class CdbRelation;
30class CdbIndex;
31class CdbUser;
32class CdbGroup;
33class CdbDocument;
34class CdbContainer;
35class CdbParameter;
36class CdbCollection;
37class CdbErrors;
38class CdbProperties;
39class CdbWorkspaces;
40class CdbDatabases;
41class CdbConnections;
42class CdbRecordsets;
43class CdbQueryDefs;
44class CdbTableDefs;
45class CdbFields;
46class CdbRelations;
47class CdbIndexes;
48class CdbUsers;
49class CdbGroups;
50class CdbDocuments;
51class CdbContainers;
52class CdbParameters;
53class CdbBStr;
54
55const char szKEY[] = "mbmabptebkjcdlgtjmskjwtsdhjbmkmwtrak";
56
57#define DAO_MAXSEEKFIELDS 13
58
59class DLLEXPORT CdbBSTR {
60public:
61 CONSTRUCTOR CdbBSTR(BSTR=NULL);
62 DESTRUCTOR ~CdbBSTR(VOID);
63 operator BSTR *(VOID);
64 operator LPCTSTR(VOID);
65private:
66 BSTR m_bstr;
67};
68
69class CdbVariant : public COleVariant {
70public:
71 CONSTRUCTOR CdbVariant(LONG l);
72 CONSTRUCTOR CdbVariant(VOID);
73 CONSTRUCTOR CdbVariant(LPCTSTR pstr);
74 CONSTRUCTOR CdbVariant(SHORT s,WINBOOL bIsBool = FALSE);
75 CONSTRUCTOR CdbVariant(LPVARIANT pv);
76 CONSTRUCTOR CdbVariant(LPSAFEARRAY psa);
77 VOID operator =(LPVARIANT pv);
78 VOID operator =(LPCTSTR pstr);
79 VOID operator =(SHORT s);
80 VOID operator =(const int i);
81 VOID operator =(LONG l);
82};
83
84inline CONSTRUCTOR CdbVariant::CdbVariant(VOID) : COleVariant() {
85 vt = VT_ERROR;
86 scode = DISP_E_PARAMNOTFOUND;
87}
88
89inline CdbVariant::CdbVariant(LONG l) {
90 if(l==-1) {
91 vt = VT_ERROR;
92 scode = DISP_E_PARAMNOTFOUND;
93 } else {
94 vt = VT_I4;
95 lVal = l;
96 }
97}
98
99inline CONSTRUCTOR CdbVariant::CdbVariant(LPCTSTR pstr): COleVariant(pstr,VT_BSTRT) {
100 if(!pstr) {
101 VariantClear(this);
102 vt = VT_ERROR;
103 scode = DISP_E_PARAMNOTFOUND;
104 }
105}
106
107inline CONSTRUCTOR CdbVariant::CdbVariant(SHORT s,WINBOOL bIsBool) : COleVariant(s) {
108 if(bIsBool) {
109 vt = VT_BOOL;
110 boolVal = s;
111 } else if(s==-1) {
112 vt = VT_ERROR;
113 scode = DISP_E_PARAMNOTFOUND;
114 }
115}
116
117inline CONSTRUCTOR CdbVariant::CdbVariant(LPVARIANT pv) {
118 if(!pv) {
119 vt = VT_ERROR;
120 scode = DISP_E_PARAMNOTFOUND;
121 } else
122 VariantCopy(this,pv);
123}
124
125inline CONSTRUCTOR CdbVariant::CdbVariant(LPSAFEARRAY psa) {
126 if(!psa) {
127 vt = VT_ERROR;
128 scode = DISP_E_PARAMNOTFOUND;
129 } else {
130 vt = VT_ARRAY|VT_UI1;
131 parray = psa;
132 }
133}
134
135inline VOID CdbVariant::operator =(LPVARIANT pv) {
136 if(!pv) {
137 vt = VT_ERROR;
138 scode = DISP_E_PARAMNOTFOUND;
139 } else
140 VariantCopy(this,pv);
141}
142
143inline VOID CdbVariant::operator =(LPCTSTR pstr) {
144 if(!pstr) {
145 VariantClear(this);
146 vt = VT_ERROR;
147 scode = DISP_E_PARAMNOTFOUND;
148 } else {
149#if defined(UNICODE)
150 bstrVal = SysAllocString(pstr);
151#else
152 bstrVal = SysAllocStringByteLen(pstr,strlen(pstr));
153#endif
154 vt = VT_BSTR;
155 }
156}
157
158inline VOID CdbVariant::operator =(SHORT s) {
159 if(s==-1) {
160 vt = VT_ERROR;
161 scode = DISP_E_PARAMNOTFOUND;
162 } else {
163 vt = VT_I2;
164 iVal = s;
165 }
166}
167
168inline VOID CdbVariant::operator =(const int i) {
169 if(i==-1) {
170 vt = VT_ERROR;
171 scode = DISP_E_PARAMNOTFOUND;
172 } else {
173 vt = VT_I2;
174 iVal =(SHORT)i;
175 }
176}
177
178inline VOID CdbVariant::operator =(LONG l) {
179 if(l==-1) {
180 vt = VT_ERROR;
181 scode = DISP_E_PARAMNOTFOUND;
182 } else {
183 vt = VT_I4;
184 lVal = l;
185 }
186}
187
188HRESULT CdbWideFromAnsi(LPSTR,unsigned int,BSTR *);
189
190class CdbWide {
191public:
192 CONSTRUCTOR CdbWide(LPSTR pstr,unsigned int cb=0) {
193 CdbWideFromAnsi(pstr,(pstr ? (cb==0 ? strlen(pstr) : cb) : 0),&m_bstr);
194 }
195 DESTRUCTOR ~CdbWide() {
196 SysFreeString(m_bstr);
197 }
198 operator LPWSTR() { return (LPWSTR)m_bstr; }
199 operator LPSTR() { return (LPSTR)m_bstr; }
200 ULONG cBytes() { return SysStringByteLen(m_bstr); }
201private:
202 BSTR m_bstr;
203};
204
205class DLLEXPORT CdbOleObject : public CObject {
206public:
207 CONSTRUCTOR CdbOleObject(VOID);
208 virtual DESTRUCTOR ~CdbOleObject(VOID);
209 WINBOOL Exists(VOID);
210 CdbOleObject &operator = (CdbOleObject &o);
211 operator LPUNKNOWN(){ return GetInterface();}
212 VOID SetInterface(LPUNKNOWN punk,WINBOOL bAddRef=FALSE);
213 VOID SetInterface(REFIID riidClass,REFIID riidInterface);
214 VOID SetInterfaceLic(REFIID riidClass,REFIID riidInterface);
215 LPUNKNOWN GetInterface(WINBOOL bAddRef=FALSE,WINBOOL bThrowException=TRUE) const;
216 virtual VOID OnInterfaceChange(VOID);
217 VOID SetRichErrorInfo(LPOLESTR pstrSource,LPOLESTR pstrDescription,LPOLESTR pstrHelpFile,ULONG ulHelpID) const;
218protected:
219 WINBOOL StartOLE(VOID);
220 LPUNKNOWN m_punkInterface;
221};
222
223class DLLEXPORT CdbCollection : public CdbOleObject {
224public:
225 virtual CdbObject ObItem(LONG i) = 0;
226 virtual CdbObject ObItem(LPCTSTR pstr) = 0;
227 virtual LONG GetCount(VOID) = 0;
228 virtual VOID ObAppend(CdbObject &obj) = 0;
229 virtual VOID Delete(LPCTSTR pstr) = 0;
230 virtual VOID Refresh(VOID) = 0;
231};
232
233class DLLEXPORT CdbStaticCollection : public CdbCollection {
234public:
235 CdbObject ObItem(LONG i);
236 CdbObject ObItem(LPCTSTR pstr);
237 LONG GetCount(VOID);
238 VOID ObAppend(CdbObject &obj);
239 VOID Delete(LPCTSTR pstr);
240 VOID Refresh(VOID);
241};
242
243class DLLEXPORT CdbDynamicCollection : public CdbCollection {
244public:
245 CdbObject ObItem(LONG i);
246 CdbObject ObItem(LPCTSTR pstr);
247 LONG GetCount(VOID);
248 VOID ObAppend(CdbObject &obj);
249 VOID Delete(LPCTSTR pstr);
250 VOID Refresh(VOID);
251};
252
253#define DAOMFC_STATIC_COLLECTION_DECL(objColl,objSingle,intSingle) class DLLEXPORT objColl : public CdbStaticCollection { public: objSingle Item(LONG i); objSingle Item(LPCTSTR pstr); objSingle operator[](LONG i); objSingle operator[](LPCTSTR pstr); }
254#define DAOMFC_DYNAMIC_COLLECTION_DECL(objColl,objSingle,intSingle) class DLLEXPORT objColl : public CdbDynamicCollection { public: objSingle Item(LONG i); objSingle Item(LPCTSTR pstr); VOID Append(objSingle &o); objSingle operator[](LONG i); objSingle operator[](LPCTSTR pstr); }
255
256DAOMFC_STATIC_COLLECTION_DECL(CdbErrors,CdbError,DAOError);
257DAOMFC_STATIC_COLLECTION_DECL(CdbDatabases,CdbDatabase,DAODatabase);
258DAOMFC_STATIC_COLLECTION_DECL(CdbRecordsets,CdbRecordset,DAORecordset);
259DAOMFC_STATIC_COLLECTION_DECL(CdbParameters,CdbParameter,DAOParameter);
260DAOMFC_STATIC_COLLECTION_DECL(CdbDocuments,CdbDocument,DAODocument);
261DAOMFC_STATIC_COLLECTION_DECL(CdbContainers,CdbContainer,DAOContainer);
262DAOMFC_DYNAMIC_COLLECTION_DECL(CdbProperties,CdbProperty,DAOProperty);
263DAOMFC_DYNAMIC_COLLECTION_DECL(CdbFields,CdbField,DAOField);
264DAOMFC_DYNAMIC_COLLECTION_DECL(CdbQueryDefs,CdbQueryDef,DAOQueryDef);
265DAOMFC_DYNAMIC_COLLECTION_DECL(CdbTableDefs,CdbTableDef,DAOTableDef);
266DAOMFC_DYNAMIC_COLLECTION_DECL(CdbIndexes,CdbIndex,DAOIndex);
267DAOMFC_DYNAMIC_COLLECTION_DECL(CdbRelations,CdbRelation,DAORelation);
268DAOMFC_DYNAMIC_COLLECTION_DECL(CdbUsers,CdbUser,DAOUser);
269DAOMFC_DYNAMIC_COLLECTION_DECL(CdbGroups,CdbGroup,DAOGroup);
270
271class DLLEXPORT CdbWorkspaces : public CdbDynamicCollection {
272 friend CdbDBEngine;
273private:
274 DAODBEngine *pDBEng;
275 WINBOOL m_bDontStart;
276public:
277 CONSTRUCTOR CdbWorkspaces(VOID){pDBEng = NULL;}
278 CdbWorkspace Item(LONG i);
279 CdbWorkspace Item(LPCTSTR pstr);
280 VOID Append(CdbWorkspace &o);
281 CdbWorkspace operator[](LONG i);
282 CdbWorkspace operator[](LPCTSTR pstr);
283 VOID SetDBEngine(DAODBEngine *peng){pDBEng = peng;}
284 VOID GetDelayedInterface();
285};
286
287class DLLEXPORT CdbConnections : public CdbStaticCollection {
288public:
289 CONSTRUCTOR CdbConnections(CdbConnections &Connections);
290 CONSTRUCTOR CdbConnections() { pwrk = NULL; }
291 CdbConnection Item(LONG i);
292 CdbConnection Item(LPCTSTR pstr);
293 CdbConnection operator[](LONG i);
294 CdbConnection operator[](LPCTSTR pstr);
295 CdbConnections &operator = (CdbConnections &o);
296 LONG GetCount(VOID);
297 VOID Refresh(VOID);
298 VOID SetWorkspace(DAOWorkspace *pParent) { pwrk = pParent; }
299private:
300 VOID CheckInterface();
301 DAOWorkspace *pwrk;
302};
303
304class DLLEXPORT CdbObject : public CdbOleObject {
305public:
306 CONSTRUCTOR CdbObject(VOID);
307 CONSTRUCTOR CdbObject(LPUNKNOWN punk,WINBOOL bAddRef=FALSE);
308 virtual CString GetName(VOID);
309 virtual VOID SetName(LPCTSTR pstr);
310 CdbProperties Properties;
311};
312
313class DLLEXPORT CdbGetRowsEx : public CdbObject {
314public:
315 CONSTRUCTOR CdbGetRowsEx(VOID);
316 CONSTRUCTOR CdbGetRowsEx(ICDAORecordset *pGetRows,WINBOOL bAddRef=FALSE);
317 CONSTRUCTOR CdbGetRowsEx(const CdbGetRowsEx &);
318 CdbGetRowsEx &operator =(const CdbGetRowsEx &);
319 VOID OnInterfaceChange(VOID);
320};
321
322#define DAOVINIT(var) do { (var).vt = VT_ERROR; (var).scode = DISP_E_PARAMNOTFOUND; } while (0)
323#define STV(pstr) CdbVariant(pstr)
324#define STB(pstr) V_BSTR(((LPVARIANT)STV(pstr)))
325#define LTV(l) CdbVariant(l)
326#define OLTV(l) CdbVariant((l))
327#define BTB(b) ((VARIANT_BOOL)(b?-1:0))
328#define BTV(b) CdbVariant(BTB(b),TRUE)
329#define SHTV(s) CdbVariant((SHORT)s)
330#define VTV(pv) CdbVariant(pv)
331#define ATV(psa,var) do { if(!psa) { var.vt = VT_ERROR; var.scode = DISP_E_PARAMNOTFOUND; } else { var.vt = VT_ARRAY|VT_UI1; SafeArrayCopy(psa,&var.parray); } } while (0)
332#define DAOMFC_CALL(hr) do { HRESULT hresult = (hr); if(FAILED(hresult)) { TRACE0("\nDBDAO Call Failed.\n\t"); TRACE2("\nIn file %s on line %d\n",_T("DBDAO.CPP"),__LINE__); TRACE1("hResult = %X\n",hresult); if(GetScode(hresult)==E_OUTOFMEMORY) AfxThrowMemoryException(); else throw CdbException(hresult); } } while (0)
333#define LPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); LONG l = 0; DAOMFC_CALL(p->meth(&l)); return l; } while (0)
334#define LPROPSET(intDAO,meth,l) do { intDAO *p = (intDAO *)GetInterface(); DAOMFC_CALL(p->meth(l)); } while(0)
335#define WPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); SHORT s = 0; DAOMFC_CALL(p->meth(&s)); return s; } while (0)
336#define WPROPSET(intDAO,meth,s) do { intDAO *p = (intDAO *)GetInterface(); DAOMFC_CALL(p->meth(s)); } while(0)
337#define SPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); CdbBSTR bstr; DAOMFC_CALL(p->meth(bstr)); return bstr; } while (0)
338#define SPROPSET(intDAO,meth,s) do { intDAO *p = (intDAO *)GetInterface(); DAOMFC_CALL(p->meth(STB(s))); } while(0)
339#define DPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); VARIANT Var; VariantInit(&Var); DAOMFC_CALL(p->meth(&Var)); return Var; } while (0)
340#define DPROPSET(intDAO,meth,pv) do { intDAO *p = (intDAO *)GetInterface(); DAOMFC_CALL(p->meth(*pv)); } while(0)
341#define BPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); VARIANT_BOOL vb = 0; DAOMFC_CALL(p->meth(&vb)); return(WINBOOL)vb; } while (0)
342#define BPROPSET(intDAO,meth,b) do { intDAO *p = (intDAO *)GetInterface(); DAOMFC_CALL(p->meth(BTB(b))); } while(0)
343#define VPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); COleVariant v; VariantInit(&v); DAOMFC_CALL(p->meth(&v)); return &v; } while (0)
344#define VPROPSET(intDAO,meth,pv) do { intDAO *p = (intDAO *)GetInterface(); DAOMFC_CALL(p->meth(*pv)); } while(0)
345#define DWPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); DWORD dw = 0; DAOMFC_CALL(p->meth(&dw)); return dw; } while (0)
346#define DAOMFC_STATIC_COLLECTION_IMPL(objColl,objSingle,intColl,intSingle) objSingle objColl::Item(LONG i) { return (intSingle *)(ObItem(i).GetInterface(TRUE)); } objSingle objColl::Item(LPCTSTR pstr) { return (intSingle *)(ObItem(pstr).GetInterface(TRUE)); } objSingle objColl::operator[](LONG i) { return (intSingle *)(Item(i).GetInterface(TRUE)); } objSingle objColl::operator[](LPCTSTR pstr) { return (intSingle *)(Item(pstr).GetInterface(TRUE)); }
347#define DAOMFC_DYNAMIC_COLLECTION_IMPL(objColl,objSingle,intColl,intSingle) objSingle objColl::Item(LONG i) { return (intSingle *)(ObItem(i).GetInterface(TRUE)); } objSingle objColl::Item(LPCTSTR pstr) { return (intSingle *)(ObItem(pstr).GetInterface(TRUE)); } VOID objColl::Append(objSingle &o) { ObAppend(o); } objSingle objColl::operator[](LONG i) { return (intSingle *)(Item(i).GetInterface(TRUE)); } objSingle objColl::operator[](LPCTSTR pstr) { return (intSingle *)(Item(pstr).GetInterface(TRUE)); }
348
349#undef INTERFACE
350#define INTERFACE DAOMFCSCollection
351DECLARE_INTERFACE_(DAOMFCSCollection,_DAOCollection) {
352#ifndef __cplusplus
353 /* IUnknown methods */
354 STDMETHOD(QueryInterface)(THIS_ REFIID riid, void **ppvObject) PURE;
355 STDMETHOD_(ULONG, AddRef)(THIS) PURE;
356 STDMETHOD_(ULONG, Release)(THIS) PURE;
357 /*** IDispatch methods ***/
358 STDMETHOD(GetTypeInfoCount)(THIS_ UINT *pctinfo);
359 STDMETHOD(GetTypeInfo)(THIS_ UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
360 STDMETHOD(GetIDsOfNames)(THIS_ REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
361 STDMETHOD(Invoke)(THIS_ DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
362 /*** _DAOCollection ***/
363 STDMETHOD(get_Count) (THIS_ short *c) PURE;
364 STDMETHOD(_NewEnum) (THIS_ IUnknown **ppunk) PURE;
365 STDMETHOD(Refresh) (THIS) PURE;
366#endif
367 STDMETHOD(get_Item) (THIS_ VARIANT index,LPUNKNOWN *ppunk);
368};
369
370#undef INTERFACE
371#define INTERFACE DAOMFCDCollection
372DECLARE_INTERFACE_(DAOMFCDCollection,_DAODynaCollection) {
373#ifndef __cplusplus
374 /* IUnknown methods */
375 STDMETHOD(QueryInterface)(THIS_ REFIID riid, void **ppvObject) PURE;
376 STDMETHOD_(ULONG, AddRef)(THIS) PURE;
377 STDMETHOD_(ULONG, Release)(THIS) PURE;
378 /*** IDispatch methods ***/
379 STDMETHOD(GetTypeInfoCount)(THIS_ UINT *pctinfo);
380 STDMETHOD(GetTypeInfo)(THIS_ UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
381 STDMETHOD(GetIDsOfNames)(THIS_ REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
382 STDMETHOD(Invoke)(THIS_ DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
383 /*** _DAOCollection ***/
384 STDMETHOD(get_Count) (THIS_ short *c) PURE;
385 STDMETHOD(_NewEnum) (THIS_ IUnknown **ppunk) PURE;
386 STDMETHOD(Refresh) (THIS) PURE;
387 /*** _DAODynaCollection ***/
388 STDMETHOD(Append) (THIS_ IDispatch *Object) PURE;
389 STDMETHOD(Delete) (THIS_ BSTR Name) PURE;
390#endif
391 STDMETHOD(get_Item) (THIS_ VARIANT index,LPUNKNOWN *ppunk);
392};
393
394#endif /* __cplusplus */
395
396#endif
Note: See TracBrowser for help on using the repository browser.