42 #ifndef _MGNCS_DATA_SOURCE_H 43 #define _MGNCS_DATA_SOURCE_H 49 typedef struct _mRecordSetClass mRecordSetClass;
50 typedef struct _mRecordSet mRecordSet;
52 typedef struct _mDataSourceClass mDataSourceClass;
53 typedef struct _mDataSource mDataSource;
55 #define NCS_DS_SELECT_READ 0x01 56 #define NCS_DS_SELECT_WRITE 0x02 58 #define MSQLITE_READONLY 0x00000001 59 #define MSQLITE_READWRITE 0x00000002 60 #define MSQLITE_CREATE 0x00000004 62 #define mDataSourceClassHeader(clss, superCls) \ 63 mObjectClassHeader(clss, superCls) \ 64 mRecordSet * (*selectRecordSet)(clss *, const char* select, int select_type); \ 65 DWORD (*getValue)(clss*, const char* mql,BOOL *bok); \ 66 BOOL (*setValue)(clss*, const char* mql, DWORD value); \ 67 mBindProp * (*getBindProp)(clss*, const char* mql, int bp_type); \ 68 BOOL (*createValue)(clss*, const char* ql, DWORD init_value); \ 69 BOOL (*removeValue)(clss*, const char* ql); \ 70 BOOL (*execute)(clss*, const char* mql); 72 struct _mDataSourceClass {
73 mDataSourceClassHeader(mDataSource,
mObject)
76 #define mDataSourceHeader(clss) \ 80 mDataSourceHeader(mDataSource)
83 MGNCS_EXPORT
extern mDataSourceClass g_stmDataSourceCls;
86 #define NCS_RS_CURSOR_BEGIN 0 87 #define NCS_RS_CURSOR_CUR 1 88 #define NCS_RS_CURSOR_END 2 90 #define NCS_RS_INSERT_AFTER 0 91 #define NCS_RS_INSERT_APPEND 1 92 #define NCS_RS_INSERT_BEFORE 2 94 #define NCS_RSE_CURSOR_UPDATE 0x01 95 #define NCS_RSE_VALUE_UPATED 0x02 96 #define NCS_RSE_VALUE_CREATE 0x04 97 #define NCS_RSE_VALUE_REMOVED 0x08 99 #define mRecordSetClassHeader(clss, superCls) \ 100 mObjectClassHeader(clss, superCls) \ 101 int (*getFieldCount)(clss*); \ 102 int (*getRecordCount)(clss*); \ 103 int (*getFieldType)(clss*, int filed_idx); \ 104 DWORD (*getCursor)(clss *); \ 105 BOOL (*setCursor)(clss *, DWORD cursor); \ 106 DWORD (*seekCursor)(clss *, int seek, int offset); \ 107 DWORD (*getField)(clss *, int idx); \ 108 BOOL (*setField)(clss *, int idx, DWORD value); \ 109 BOOL (*newRecord)(clss *, int insert_type); \ 110 BOOL (*deleteRecord)(clss *); \ 111 BOOL (*update)(clss *); \ 112 BOOL (*cancel)(clss *); \ 113 BOOL (*isEnd)(clss *); \ 114 mBindProp * (*getFieldBind)(clss *, int field_idx, int event_filter, int bp_type); \ 115 mBindProp * (*getCursorBind)(clss *, int bp_type); 117 struct _mRecordSetClass{
118 mRecordSetClassHeader(mRecordSet,
mObject)
121 #define mRecordSetHeader(clss) \ 125 mRecordSetHeader(mRecordSet)
128 MGNCS_EXPORT
extern mRecordSetClass g_stmRecordSetCls;
133 typedef struct _mDataBindPropClass mDataBindPropClass;
134 typedef struct _mDataBindProp mDataBindProp;
136 #define mDataBindPropClassHeader(clss, supper) \ 137 mBindPropClassHeader(clss, supper) \ 139 struct _mDataBindPropClass{
140 mDataBindPropClassHeader(mDataBindProp, mBindProp)
143 MGNCS_EXPORT
extern mDataBindPropClass g_stmDataBindPropCls;
145 #define mDataBindPropHeader(clss) \ 146 mBindPropHeader(clss) \ 147 unsigned int event_filter:16; \ 148 unsigned int revert:16; 150 struct _mDataBindProp {
151 mDataBindPropHeader(mDataBindProp)
154 typedef struct _mDataValueBindPropClass mDataValueBindPropClass;
155 typedef struct _mDataValueBindProp mDataValueBindProp;
157 #define mDataValueBindPropClassHeader(clss, super) \ 158 mDataBindPropClassHeader(clss, super) 160 struct _mDataValueBindPropClass{
161 mDataValueBindPropClassHeader(mDataValueBindProp, mDataBindProp)
164 #define mDataValueBindPropHeader(clss) \ 165 mDataBindPropHeader(clss) \ 168 struct _mDataValueBindProp{
169 mDataValueBindPropHeader(mDataValueBindProp)
173 typedef struct _mDataFieldBindPropClass mDataFieldBindPropClass;
174 typedef struct _mDataFieldBindProp mDataFieldBindProp;
176 #define mDataFieldBindPropClassHeader(clss, super) \ 177 mDataBindPropClassHeader(clss, super) 179 struct _mDataFieldBindPropClass {
180 mDataFieldBindPropClassHeader(mDataFieldBindProp, mDataBindProp)
183 #define mDataFieldBindPropHeader(clss) \ 184 mDataBindPropHeader(clss) \ 185 mRecordSet * recordSet; 189 struct _mDataFieldBindProp {
190 mDataFieldBindPropHeader(mDataFieldBindProp)
194 MGNCS_EXPORT
void ncsRaiseDataSourceBindProps(
mObject *obj,
int event_filter);
196 MGNCS_EXPORT mBindProp * ncsRegisterDataValueBindProp(mDataSource *obj, DWORD *pvalue,
int type,
int flags,
int event_filter);
198 MGNCS_EXPORT mBindProp * ncsRegisterDataFieldBindProp(mRecordSet *rs,
int field_idx,
int flags,
int event_filter);
200 #define DATA_VAR_PROP(owner, pvalue ,data_type, flags, event_filter) \ 201 ncsRegisterDataValueBindProp((mDataSource*)(owner), (DWORD*)(pvalue), (int)(data_type), (int)(flags), (int)(event_filter)); 203 #define DATA_FIELD_PROP(rs, field, flags, event_filer) \ 204 ncsRegisterDataFieldBindProp((mRecordSet*)(rs), (int)(field), (int)(flags), (int)(event_filter)) 210 BOOL ncsInitDefaultDataSource(
void);
212 MGNCS_EXPORT
extern mDataSource* g_pStaticDS;
214 MGNCS_EXPORT BOOL ncsRegisterStaticData(
const char* pvalue_path,
void ** array,
int array_count,
int field_count,
int filed_width,
const unsigned char* field_types);
216 MGNCS_EXPORT BOOL ncsRegisterStaticValue(
const char* pvalue_path, DWORD value,
int type);
217 #define ncsRegisterStaticString(pvalue_path, str) do{ \ 218 static char _str[] = str; \ 219 ncsRegisterStaticValue(pvalue_path, _str, NCS_BT_STR; \ 224 MGNCS_EXPORT mDataSource* ncsCreateTextDataSource(
const char* source_file,
int spliter,
int mode);
227 MGNCS_EXPORT mDataSource* ncsCreateEtcDataSource(
const char* etc_file,
int mode);
229 MGNCS_EXPORT mDataSource* ncsCreateEtcDataSourceByHandle(GHANDLE hEtc,
int mode);
232 #ifdef _MGNCSDB_SQLITE 233 MGNCS_EXPORT mDataSource* ncsCreateSQLiteDataSource(
const char* sqlite_file,
int mode);