mGNCS API Reference  v1.5.0
A new control set and a new framework for MiniGUI apps
mdatasource.h
Go to the documentation of this file.
1 //
3 // IMPORTANT NOTICE
4 //
5 // The following open source license statement does not apply to any
6 // entity in the Exception List published by FMSoft.
7 //
8 // For more information, please visit:
9 //
10 // https://www.fmsoft.cn/exception-list
11 //
13 
54 #ifndef _MGNCS_DATA_SOURCE_H
55 #define _MGNCS_DATA_SOURCE_H
56 
57 #ifdef __cplusplus
58 extern "C"{
59 #endif
60 
61 typedef struct _mRecordSetClass mRecordSetClass;
62 typedef struct _mRecordSet mRecordSet;
63 
64 typedef struct _mDataSourceClass mDataSourceClass;
65 typedef struct _mDataSource mDataSource;
66 
67 #define NCS_DS_SELECT_READ 0x01
68 #define NCS_DS_SELECT_WRITE 0x02
69 
70 #define MSQLITE_READONLY 0x00000001
71 #define MSQLITE_READWRITE 0x00000002
72 #define MSQLITE_CREATE 0x00000004
73 
74 #define mDataSourceClassHeader(clss, superCls) \
75  mObjectClassHeader(clss, superCls) \
76  mRecordSet * (*selectRecordSet)(clss *, const char* select, int select_type); \
77  DWORD (*getValue)(clss*, const char* mql,BOOL *bok); \
78  BOOL (*setValue)(clss*, const char* mql, DWORD value); \
79  mBindProp * (*getBindProp)(clss*, const char* mql, int bp_type); \
80  BOOL (*createValue)(clss*, const char* ql, DWORD init_value); \
81  BOOL (*removeValue)(clss*, const char* ql); \
82  BOOL (*execute)(clss*, const char* mql); /*execute the query language*/
83 
84 struct _mDataSourceClass {
85  mDataSourceClassHeader(mDataSource, mObject)
86 };
87 
88 #define mDataSourceHeader(clss) \
89  mObjectHeader(clss)
90 
91 struct _mDataSource {
92  mDataSourceHeader(mDataSource)
93 };
94 
95 MGNCS_EXPORT extern mDataSourceClass g_stmDataSourceCls;
96 
98 #define NCS_RS_CURSOR_BEGIN 0
99 #define NCS_RS_CURSOR_CUR 1
100 #define NCS_RS_CURSOR_END 2
101 
102 #define NCS_RS_INSERT_AFTER 0
103 #define NCS_RS_INSERT_APPEND 1
104 #define NCS_RS_INSERT_BEFORE 2
105 
106 #define NCS_RSE_CURSOR_UPDATE 0x01
107 #define NCS_RSE_VALUE_UPATED 0x02
108 #define NCS_RSE_VALUE_CREATE 0x04
109 #define NCS_RSE_VALUE_REMOVED 0x08
110 
111 #define mRecordSetClassHeader(clss, superCls) \
112  mObjectClassHeader(clss, superCls) \
113  int (*getFieldCount)(clss*); \
114  int (*getRecordCount)(clss*); \
115  int (*getFieldType)(clss*, int filed_idx); \
116  DWORD (*getCursor)(clss *); \
117  BOOL (*setCursor)(clss *, DWORD cursor); \
118  DWORD (*seekCursor)(clss *, int seek, int offset); \
119  DWORD (*getField)(clss *, int idx); \
120  BOOL (*setField)(clss *, int idx, DWORD value); \
121  BOOL (*newRecord)(clss *, int insert_type); \
122  BOOL (*deleteRecord)(clss *); \
123  BOOL (*update)(clss *); \
124  BOOL (*cancel)(clss *); \
125  BOOL (*isEnd)(clss *); \
126  mBindProp * (*getFieldBind)(clss *, int field_idx, int event_filter, int bp_type); \
127  mBindProp * (*getCursorBind)(clss *, int bp_type);
128 
129 struct _mRecordSetClass{
130  mRecordSetClassHeader(mRecordSet, mObject)
131 };
132 
133 #define mRecordSetHeader(clss) \
134  mObjectHeader(clss)
135 
136 struct _mRecordSet{
137  mRecordSetHeader(mRecordSet)
138 };
139 
140 MGNCS_EXPORT extern mRecordSetClass g_stmRecordSetCls;
141 
143 // Bind Prop
144 
145 typedef struct _mDataBindPropClass mDataBindPropClass;
146 typedef struct _mDataBindProp mDataBindProp;
147 
148 #define mDataBindPropClassHeader(clss, supper) \
149  mBindPropClassHeader(clss, supper) \
150 
151 struct _mDataBindPropClass{
152  mDataBindPropClassHeader(mDataBindProp, mBindProp)
153 };
154 
155 MGNCS_EXPORT extern mDataBindPropClass g_stmDataBindPropCls;
156 
157 #define mDataBindPropHeader(clss) \
158  mBindPropHeader(clss) \
159  unsigned int event_filter:16; \
160  unsigned int revert:16;
161 
162 struct _mDataBindProp {
163  mDataBindPropHeader(mDataBindProp)
164 };
165 
166 typedef struct _mDataValueBindPropClass mDataValueBindPropClass;
167 typedef struct _mDataValueBindProp mDataValueBindProp;
168 
169 #define mDataValueBindPropClassHeader(clss, super) \
170  mDataBindPropClassHeader(clss, super)
171 
172 struct _mDataValueBindPropClass{
173  mDataValueBindPropClassHeader(mDataValueBindProp, mDataBindProp)
174 };
175 
176 #define mDataValueBindPropHeader(clss) \
177  mDataBindPropHeader(clss) \
178  DWORD *pvalue;
179 
180 struct _mDataValueBindProp{
181  mDataValueBindPropHeader(mDataValueBindProp)
182 };
183 
184 
185 typedef struct _mDataFieldBindPropClass mDataFieldBindPropClass;
186 typedef struct _mDataFieldBindProp mDataFieldBindProp;
187 
188 #define mDataFieldBindPropClassHeader(clss, super) \
189  mDataBindPropClassHeader(clss, super)
190 
191 struct _mDataFieldBindPropClass {
192  mDataFieldBindPropClassHeader(mDataFieldBindProp, mDataBindProp)
193 };
194 
195 #define mDataFieldBindPropHeader(clss) \
196  mDataBindPropHeader(clss) \
197  mRecordSet * recordSet;
198 
199 //user mDataBindProp::revert as field_idx
200 
201 struct _mDataFieldBindProp {
202  mDataFieldBindPropHeader(mDataFieldBindProp)
203 };
204 
205 
206 MGNCS_EXPORT void ncsRaiseDataSourceBindProps(mObject *obj, int event_filter);
207 
208 MGNCS_EXPORT mBindProp * ncsRegisterDataValueBindProp(mDataSource *obj, DWORD *pvalue, int type, int flags, int event_filter);
209 
210 MGNCS_EXPORT mBindProp * ncsRegisterDataFieldBindProp(mRecordSet *rs, int field_idx, int flags, int event_filter);
211 
212 #define DATA_VAR_PROP(owner, pvalue ,data_type, flags, event_filter) \
213  ncsRegisterDataValueBindProp((mDataSource*)(owner), (DWORD*)(pvalue), (int)(data_type), (int)(flags), (int)(event_filter));
214 
215 #define DATA_FIELD_PROP(rs, field, flags, event_filer) \
216  ncsRegisterDataFieldBindProp((mRecordSet*)(rs), (int)(field), (int)(flags), (int)(event_filter))
217 
218 
220 // Default DataSource
221 
222 BOOL ncsInitDefaultDataSource(void);
223 //mStaticDataSource
224 MGNCS_EXPORT extern mDataSource* g_pStaticDS;
225 
226 MGNCS_EXPORT BOOL ncsRegisterStaticData(const char* pvalue_path, void ** array, int array_count, int field_count, int filed_width, const unsigned char* field_types);
227 
228 MGNCS_EXPORT BOOL ncsRegisterStaticValue(const char* pvalue_path, DWORD value, int type);
229 #define ncsRegisterStaticString(pvalue_path, str) do{ \
230  static char _str[] = str; \
231  ncsRegisterStaticValue(pvalue_path, _str, NCS_BT_STR; \
232 }while(0)
233 
234 
235 //mTextDataSource
236 MGNCS_EXPORT mDataSource* ncsCreateTextDataSource(const char* source_file, int spliter, int mode);
237 
238 //mEtcDataSource
239 MGNCS_EXPORT mDataSource* ncsCreateEtcDataSource(const char* etc_file, int mode);
240 
241 MGNCS_EXPORT mDataSource* ncsCreateEtcDataSourceByHandle(GHANDLE hEtc, int mode);
242 
243 //mSQLiteDataSource
244 #ifdef _MGNCSDB_SQLITE
245 MGNCS_EXPORT mDataSource* ncsCreateSQLiteDataSource(const char* sqlite_file, int mode);
246 #endif
247 
249 
250 
251 #ifdef __cplusplus
252 }
253 #endif
254 
255 #endif
256 
mObject
the Object struct