comparison fuhtark_test/include/winapi/_dbdao.h @ 1500:91c8c3b7cbf0

add: futhark tests for generating vulkan api
author sam <sam@basx.dev>
date Wed, 26 Nov 2025 21:36:48 +0700
parents
children
comparison
equal deleted inserted replaced
1499:1f58458b7ef7 1500:91c8c3b7cbf0
1 #ifndef __DBDAO_H_
2 #define __DBDAO_H_
3
4 #ifndef __cplusplus
5 #error This file can be used only in C++
6 #else
7
8 class COleVariant;
9 class CdbBookmark;
10 class CdbException;
11 class CdbOleObject;
12 class CdbObject;
13 class CdbError;
14 class CdbProperty;
15 class CdbDBEngine;
16 class CdbWorkspace;
17 class CdbDatabase;
18 class CdbConnection;
19 class CdbRecordset;
20 class CdbGetRowsEx;
21 class CdbQueryDef;
22 class CdbTableDef;
23 class CdbField;
24 class CdbRelation;
25 class CdbIndex;
26 class CdbUser;
27 class CdbGroup;
28 class CdbDocument;
29 class CdbContainer;
30 class CdbParameter;
31 class CdbCollection;
32 class CdbErrors;
33 class CdbProperties;
34 class CdbWorkspaces;
35 class CdbDatabases;
36 class CdbConnections;
37 class CdbRecordsets;
38 class CdbQueryDefs;
39 class CdbTableDefs;
40 class CdbFields;
41 class CdbRelations;
42 class CdbIndexes;
43 class CdbUsers;
44 class CdbGroups;
45 class CdbDocuments;
46 class CdbContainers;
47 class CdbParameters;
48 class CdbBStr;
49
50 const char szKEY[] = "mbmabptebkjcdlgtjmskjwtsdhjbmkmwtrak";
51
52 #define DAO_MAXSEEKFIELDS 13
53
54 class DLLEXPORT CdbBSTR {
55 public:
56 CONSTRUCTOR CdbBSTR(BSTR=NULL);
57 DESTRUCTOR ~CdbBSTR(VOID);
58 operator BSTR *(VOID);
59 operator LPCTSTR(VOID);
60 private:
61 BSTR m_bstr;
62 };
63
64 class CdbVariant : public COleVariant {
65 public:
66 CONSTRUCTOR CdbVariant(LONG l);
67 CONSTRUCTOR CdbVariant(VOID);
68 CONSTRUCTOR CdbVariant(LPCTSTR pstr);
69 CONSTRUCTOR CdbVariant(SHORT s,WINBOOL bIsBool = FALSE);
70 CONSTRUCTOR CdbVariant(LPVARIANT pv);
71 CONSTRUCTOR CdbVariant(LPSAFEARRAY psa);
72 VOID operator =(LPVARIANT pv);
73 VOID operator =(LPCTSTR pstr);
74 VOID operator =(SHORT s);
75 VOID operator =(const int i);
76 VOID operator =(LONG l);
77 };
78
79 inline CONSTRUCTOR CdbVariant::CdbVariant(VOID) : COleVariant() {
80 vt = VT_ERROR;
81 scode = DISP_E_PARAMNOTFOUND;
82 }
83
84 inline CdbVariant::CdbVariant(LONG l) {
85 if(l==-1) {
86 vt = VT_ERROR;
87 scode = DISP_E_PARAMNOTFOUND;
88 } else {
89 vt = VT_I4;
90 lVal = l;
91 }
92 }
93
94 inline CONSTRUCTOR CdbVariant::CdbVariant(LPCTSTR pstr): COleVariant(pstr,VT_BSTRT) {
95 if(!pstr) {
96 VariantClear(this);
97 vt = VT_ERROR;
98 scode = DISP_E_PARAMNOTFOUND;
99 }
100 }
101
102 inline CONSTRUCTOR CdbVariant::CdbVariant(SHORT s,WINBOOL bIsBool) : COleVariant(s) {
103 if(bIsBool) {
104 vt = VT_BOOL;
105 boolVal = s;
106 } else if(s==-1) {
107 vt = VT_ERROR;
108 scode = DISP_E_PARAMNOTFOUND;
109 }
110 }
111
112 inline CONSTRUCTOR CdbVariant::CdbVariant(LPVARIANT pv) {
113 if(!pv) {
114 vt = VT_ERROR;
115 scode = DISP_E_PARAMNOTFOUND;
116 } else
117 VariantCopy(this,pv);
118 }
119
120 inline CONSTRUCTOR CdbVariant::CdbVariant(LPSAFEARRAY psa) {
121 if(!psa) {
122 vt = VT_ERROR;
123 scode = DISP_E_PARAMNOTFOUND;
124 } else {
125 vt = VT_ARRAY|VT_UI1;
126 parray = psa;
127 }
128 }
129
130 inline VOID CdbVariant::operator =(LPVARIANT pv) {
131 if(!pv) {
132 vt = VT_ERROR;
133 scode = DISP_E_PARAMNOTFOUND;
134 } else
135 VariantCopy(this,pv);
136 }
137
138 inline VOID CdbVariant::operator =(LPCTSTR pstr) {
139 if(!pstr) {
140 VariantClear(this);
141 vt = VT_ERROR;
142 scode = DISP_E_PARAMNOTFOUND;
143 } else {
144 #ifdef UNICODE
145 bstrVal = SysAllocString(pstr);
146 #else
147 bstrVal = SysAllocStringByteLen(pstr,strlen(pstr));
148 #endif
149 vt = VT_BSTR;
150 }
151 }
152
153 inline VOID CdbVariant::operator =(SHORT s) {
154 if(s==-1) {
155 vt = VT_ERROR;
156 scode = DISP_E_PARAMNOTFOUND;
157 } else {
158 vt = VT_I2;
159 iVal = s;
160 }
161 }
162
163 inline VOID CdbVariant::operator =(const int i) {
164 if(i==-1) {
165 vt = VT_ERROR;
166 scode = DISP_E_PARAMNOTFOUND;
167 } else {
168 vt = VT_I2;
169 iVal =(SHORT)i;
170 }
171 }
172
173 inline VOID CdbVariant::operator =(LONG l) {
174 if(l==-1) {
175 vt = VT_ERROR;
176 scode = DISP_E_PARAMNOTFOUND;
177 } else {
178 vt = VT_I4;
179 lVal = l;
180 }
181 }
182
183 HRESULT CdbWideFromAnsi(LPSTR,unsigned int,BSTR *);
184
185 class CdbWide {
186 public:
187 CONSTRUCTOR CdbWide(LPSTR pstr,unsigned int cb=0) {
188 CdbWideFromAnsi(pstr,(pstr ? (cb==0 ? strlen(pstr) : cb) : 0),&m_bstr);
189 }
190 DESTRUCTOR ~CdbWide() {
191 SysFreeString(m_bstr);
192 }
193 operator LPWSTR() { return (LPWSTR)m_bstr; }
194 operator LPSTR() { return (LPSTR)m_bstr; }
195 ULONG cBytes() { return SysStringByteLen(m_bstr); }
196 private:
197 BSTR m_bstr;
198 };
199
200 class DLLEXPORT CdbOleObject : public CObject {
201 public:
202 CONSTRUCTOR CdbOleObject(VOID);
203 virtual DESTRUCTOR ~CdbOleObject(VOID);
204 WINBOOL Exists(VOID);
205 CdbOleObject &operator = (CdbOleObject &o);
206 operator LPUNKNOWN(){ return GetInterface();}
207 VOID SetInterface(LPUNKNOWN punk,WINBOOL bAddRef=FALSE);
208 VOID SetInterface(REFIID riidClass,REFIID riidInterface);
209 VOID SetInterfaceLic(REFIID riidClass,REFIID riidInterface);
210 LPUNKNOWN GetInterface(WINBOOL bAddRef=FALSE,WINBOOL bThrowException=TRUE) const;
211 virtual VOID OnInterfaceChange(VOID);
212 VOID SetRichErrorInfo(LPOLESTR pstrSource,LPOLESTR pstrDescription,LPOLESTR pstrHelpFile,ULONG ulHelpID) const;
213 protected:
214 WINBOOL StartOLE(VOID);
215 LPUNKNOWN m_punkInterface;
216 };
217
218 class DLLEXPORT CdbCollection : public CdbOleObject {
219 public:
220 virtual CdbObject ObItem(LONG i) = 0;
221 virtual CdbObject ObItem(LPCTSTR pstr) = 0;
222 virtual LONG GetCount(VOID) = 0;
223 virtual VOID ObAppend(CdbObject &obj) = 0;
224 virtual VOID Delete(LPCTSTR pstr) = 0;
225 virtual VOID Refresh(VOID) = 0;
226 };
227
228 class DLLEXPORT CdbStaticCollection : public CdbCollection {
229 public:
230 CdbObject ObItem(LONG i);
231 CdbObject ObItem(LPCTSTR pstr);
232 LONG GetCount(VOID);
233 VOID ObAppend(CdbObject &obj);
234 VOID Delete(LPCTSTR pstr);
235 VOID Refresh(VOID);
236 };
237
238 class DLLEXPORT CdbDynamicCollection : public CdbCollection {
239 public:
240 CdbObject ObItem(LONG i);
241 CdbObject ObItem(LPCTSTR pstr);
242 LONG GetCount(VOID);
243 VOID ObAppend(CdbObject &obj);
244 VOID Delete(LPCTSTR pstr);
245 VOID Refresh(VOID);
246 };
247
248 #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); }
249 #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); }
250
251 DAOMFC_STATIC_COLLECTION_DECL(CdbErrors,CdbError,DAOError);
252 DAOMFC_STATIC_COLLECTION_DECL(CdbDatabases,CdbDatabase,DAODatabase);
253 DAOMFC_STATIC_COLLECTION_DECL(CdbRecordsets,CdbRecordset,DAORecordset);
254 DAOMFC_STATIC_COLLECTION_DECL(CdbParameters,CdbParameter,DAOParameter);
255 DAOMFC_STATIC_COLLECTION_DECL(CdbDocuments,CdbDocument,DAODocument);
256 DAOMFC_STATIC_COLLECTION_DECL(CdbContainers,CdbContainer,DAOContainer);
257 DAOMFC_DYNAMIC_COLLECTION_DECL(CdbProperties,CdbProperty,DAOProperty);
258 DAOMFC_DYNAMIC_COLLECTION_DECL(CdbFields,CdbField,DAOField);
259 DAOMFC_DYNAMIC_COLLECTION_DECL(CdbQueryDefs,CdbQueryDef,DAOQueryDef);
260 DAOMFC_DYNAMIC_COLLECTION_DECL(CdbTableDefs,CdbTableDef,DAOTableDef);
261 DAOMFC_DYNAMIC_COLLECTION_DECL(CdbIndexes,CdbIndex,DAOIndex);
262 DAOMFC_DYNAMIC_COLLECTION_DECL(CdbRelations,CdbRelation,DAORelation);
263 DAOMFC_DYNAMIC_COLLECTION_DECL(CdbUsers,CdbUser,DAOUser);
264 DAOMFC_DYNAMIC_COLLECTION_DECL(CdbGroups,CdbGroup,DAOGroup);
265
266 class DLLEXPORT CdbWorkspaces : public CdbDynamicCollection {
267 friend CdbDBEngine;
268 private:
269 DAODBEngine *pDBEng;
270 WINBOOL m_bDontStart;
271 public:
272 CONSTRUCTOR CdbWorkspaces(VOID){pDBEng = NULL;}
273 CdbWorkspace Item(LONG i);
274 CdbWorkspace Item(LPCTSTR pstr);
275 VOID Append(CdbWorkspace &o);
276 CdbWorkspace operator[](LONG i);
277 CdbWorkspace operator[](LPCTSTR pstr);
278 VOID SetDBEngine(DAODBEngine *peng){pDBEng = peng;}
279 VOID GetDelayedInterface();
280 };
281
282 class DLLEXPORT CdbConnections : public CdbStaticCollection {
283 public:
284 CONSTRUCTOR CdbConnections(CdbConnections &Connections);
285 CONSTRUCTOR CdbConnections() { pwrk = NULL; }
286 CdbConnection Item(LONG i);
287 CdbConnection Item(LPCTSTR pstr);
288 CdbConnection operator[](LONG i);
289 CdbConnection operator[](LPCTSTR pstr);
290 CdbConnections &operator = (CdbConnections &o);
291 LONG GetCount(VOID);
292 VOID Refresh(VOID);
293 VOID SetWorkspace(DAOWorkspace *pParent) { pwrk = pParent; }
294 private:
295 VOID CheckInterface();
296 DAOWorkspace *pwrk;
297 };
298
299 class DLLEXPORT CdbObject : public CdbOleObject {
300 public:
301 CONSTRUCTOR CdbObject(VOID);
302 CONSTRUCTOR CdbObject(LPUNKNOWN punk,WINBOOL bAddRef=FALSE);
303 virtual CString GetName(VOID);
304 virtual VOID SetName(LPCTSTR pstr);
305 CdbProperties Properties;
306 };
307
308 class DLLEXPORT CdbGetRowsEx : public CdbObject {
309 public:
310 CONSTRUCTOR CdbGetRowsEx(VOID);
311 CONSTRUCTOR CdbGetRowsEx(ICDAORecordset *pGetRows,WINBOOL bAddRef=FALSE);
312 CONSTRUCTOR CdbGetRowsEx(const CdbGetRowsEx &);
313 CdbGetRowsEx &operator =(const CdbGetRowsEx &);
314 VOID OnInterfaceChange(VOID);
315 };
316
317 #define DAOVINIT(var) do { (var).vt = VT_ERROR; (var).scode = DISP_E_PARAMNOTFOUND; } while (0)
318 #define STV(pstr) CdbVariant(pstr)
319 #define STB(pstr) V_BSTR(((LPVARIANT)STV(pstr)))
320 #define LTV(l) CdbVariant(l)
321 #define OLTV(l) CdbVariant((l))
322 #define BTB(b) ((VARIANT_BOOL)(b?-1:0))
323 #define BTV(b) CdbVariant(BTB(b),TRUE)
324 #define SHTV(s) CdbVariant((SHORT)s)
325 #define VTV(pv) CdbVariant(pv)
326 #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)
327 #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)
328 #define LPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); LONG l = 0; DAOMFC_CALL(p->meth(&l)); return l; } while (0)
329 #define LPROPSET(intDAO,meth,l) do { intDAO *p = (intDAO *)GetInterface(); DAOMFC_CALL(p->meth(l)); } while(0)
330 #define WPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); SHORT s = 0; DAOMFC_CALL(p->meth(&s)); return s; } while (0)
331 #define WPROPSET(intDAO,meth,s) do { intDAO *p = (intDAO *)GetInterface(); DAOMFC_CALL(p->meth(s)); } while(0)
332 #define SPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); CdbBSTR bstr; DAOMFC_CALL(p->meth(bstr)); return bstr; } while (0)
333 #define SPROPSET(intDAO,meth,s) do { intDAO *p = (intDAO *)GetInterface(); DAOMFC_CALL(p->meth(STB(s))); } while(0)
334 #define DPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); VARIANT Var; VariantInit(&Var); DAOMFC_CALL(p->meth(&Var)); return Var; } while (0)
335 #define DPROPSET(intDAO,meth,pv) do { intDAO *p = (intDAO *)GetInterface(); DAOMFC_CALL(p->meth(*pv)); } while(0)
336 #define BPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); VARIANT_BOOL vb = 0; DAOMFC_CALL(p->meth(&vb)); return(WINBOOL)vb; } while (0)
337 #define BPROPSET(intDAO,meth,b) do { intDAO *p = (intDAO *)GetInterface(); DAOMFC_CALL(p->meth(BTB(b))); } while(0)
338 #define VPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); COleVariant v; VariantInit(&v); DAOMFC_CALL(p->meth(&v)); return &v; } while (0)
339 #define VPROPSET(intDAO,meth,pv) do { intDAO *p = (intDAO *)GetInterface(); DAOMFC_CALL(p->meth(*pv)); } while(0)
340 #define DWPROPGET(intDAO,meth) do { intDAO *p = (intDAO *)GetInterface(); DWORD dw = 0; DAOMFC_CALL(p->meth(&dw)); return dw; } while (0)
341 #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)); }
342 #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)); }
343
344 DECLARE_INTERFACE_(DAOMFCSCollection,_DAOCollection) {
345 STDMETHOD(get_Item) (VARIANT index,LPUNKNOWN *ppunk);
346 };
347
348 DECLARE_INTERFACE_(DAOMFCDCollection,_DAODynaCollection) {
349 STDMETHOD(get_Item) (VARIANT index,LPUNKNOWN *ppunk);
350 };
351
352 #endif /* __cplusplus */
353
354 #endif