54 #ifndef _MGNCS_DATA_SOURCE_H
55 #define _MGNCS_DATA_SOURCE_H
61 typedef struct _mRecordSetClass mRecordSetClass;
62 typedef struct _mRecordSet mRecordSet;
64 typedef struct _mDataSourceClass mDataSourceClass;
65 typedef struct _mDataSource mDataSource;
67 #define NCS_DS_SELECT_READ 0x01
68 #define NCS_DS_SELECT_WRITE 0x02
70 #define MSQLITE_READONLY 0x00000001
71 #define MSQLITE_READWRITE 0x00000002
72 #define MSQLITE_CREATE 0x00000004
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);
84 struct _mDataSourceClass {
85 mDataSourceClassHeader(mDataSource,
mObject)
88 #define mDataSourceHeader(clss) \
92 mDataSourceHeader(mDataSource)
95 MGNCS_EXPORT
extern mDataSourceClass g_stmDataSourceCls;
98 #define NCS_RS_CURSOR_BEGIN 0
99 #define NCS_RS_CURSOR_CUR 1
100 #define NCS_RS_CURSOR_END 2
102 #define NCS_RS_INSERT_AFTER 0
103 #define NCS_RS_INSERT_APPEND 1
104 #define NCS_RS_INSERT_BEFORE 2
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
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);
129 struct _mRecordSetClass{
130 mRecordSetClassHeader(mRecordSet,
mObject)
133 #define mRecordSetHeader(clss) \
137 mRecordSetHeader(mRecordSet)
140 MGNCS_EXPORT
extern mRecordSetClass g_stmRecordSetCls;
145 typedef struct _mDataBindPropClass mDataBindPropClass;
146 typedef struct _mDataBindProp mDataBindProp;
148 #define mDataBindPropClassHeader(clss, supper) \
149 mBindPropClassHeader(clss, supper) \
151 struct _mDataBindPropClass{
152 mDataBindPropClassHeader(mDataBindProp, mBindProp)
155 MGNCS_EXPORT
extern mDataBindPropClass g_stmDataBindPropCls;
157 #define mDataBindPropHeader(clss) \
158 mBindPropHeader(clss) \
159 unsigned int event_filter:16; \
160 unsigned int revert:16;
162 struct _mDataBindProp {
163 mDataBindPropHeader(mDataBindProp)
166 typedef struct _mDataValueBindPropClass mDataValueBindPropClass;
167 typedef struct _mDataValueBindProp mDataValueBindProp;
169 #define mDataValueBindPropClassHeader(clss, super) \
170 mDataBindPropClassHeader(clss, super)
172 struct _mDataValueBindPropClass{
173 mDataValueBindPropClassHeader(mDataValueBindProp, mDataBindProp)
176 #define mDataValueBindPropHeader(clss) \
177 mDataBindPropHeader(clss) \
180 struct _mDataValueBindProp{
181 mDataValueBindPropHeader(mDataValueBindProp)
185 typedef struct _mDataFieldBindPropClass mDataFieldBindPropClass;
186 typedef struct _mDataFieldBindProp mDataFieldBindProp;
188 #define mDataFieldBindPropClassHeader(clss, super) \
189 mDataBindPropClassHeader(clss, super)
191 struct _mDataFieldBindPropClass {
192 mDataFieldBindPropClassHeader(mDataFieldBindProp, mDataBindProp)
195 #define mDataFieldBindPropHeader(clss) \
196 mDataBindPropHeader(clss) \
197 mRecordSet * recordSet;
201 struct _mDataFieldBindProp {
202 mDataFieldBindPropHeader(mDataFieldBindProp)
206 MGNCS_EXPORT
void ncsRaiseDataSourceBindProps(
mObject *obj,
int event_filter);
208 MGNCS_EXPORT mBindProp * ncsRegisterDataValueBindProp(mDataSource *obj, DWORD *pvalue,
int type,
int flags,
int event_filter);
210 MGNCS_EXPORT mBindProp * ncsRegisterDataFieldBindProp(mRecordSet *rs,
int field_idx,
int flags,
int event_filter);
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));
215 #define DATA_FIELD_PROP(rs, field, flags, event_filer) \
216 ncsRegisterDataFieldBindProp((mRecordSet*)(rs), (int)(field), (int)(flags), (int)(event_filter))
222 BOOL ncsInitDefaultDataSource(
void);
224 MGNCS_EXPORT
extern mDataSource* g_pStaticDS;
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);
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; \
236 MGNCS_EXPORT mDataSource* ncsCreateTextDataSource(
const char* source_file,
int spliter,
int mode);
239 MGNCS_EXPORT mDataSource* ncsCreateEtcDataSource(
const char* etc_file,
int mode);
241 MGNCS_EXPORT mDataSource* ncsCreateEtcDataSourceByHandle(GHANDLE hEtc,
int mode);
244 #ifdef _MGNCSDB_SQLITE
245 MGNCS_EXPORT mDataSource* ncsCreateSQLiteDataSource(
const char* sqlite_file,
int mode);