mdatasource.h

00001 #ifndef _MGNCS_DATA_SOURCE_H
00002 #define _MGNCS_DATA_SOURCE_H
00003 
00004 #ifdef __cplusplus
00005 extern "C"{
00006 #endif
00007 
00008 typedef struct _mRecordSetClass mRecordSetClass;
00009 typedef struct _mRecordSet mRecordSet;
00010 
00011 typedef struct _mDataSourceClass mDataSourceClass;
00012 typedef struct _mDataSource mDataSource;
00013 
00014 #define NCS_DS_SELECT_READ  0x01
00015 #define NCS_DS_SELECT_WRITE 0x02
00016 
00017 #define MSQLITE_READONLY                0x00000001
00018 #define MSQLITE_READWRITE               0x00000002
00019 #define MSQLITE_CREATE                  0x00000004
00020 
00021 #define mDataSourceClassHeader(clss, superCls) \
00022         mObjectClassHeader(clss, superCls) \
00023         mRecordSet * (*selectRecordSet)(clss *, const char* select, int select_type);  \
00024         DWORD (*getValue)(clss*, const char* mql,BOOL *bok); \
00025         BOOL  (*setValue)(clss*, const char* mql, DWORD value); \
00026         mBindProp * (*getBindProp)(clss*, const char* mql, int bp_type); \
00027         BOOL  (*createValue)(clss*, const char* ql, DWORD init_value); \
00028         BOOL  (*removeValue)(clss*, const char* ql);                   \
00029         BOOL  (*execute)(clss*, const char* mql); /*execute the query language*/
00030 
00031 struct _mDataSourceClass {
00032         mDataSourceClassHeader(mDataSource, mObject)
00033 };
00034 
00035 #define mDataSourceHeader(clss) \
00036         mObjectHeader(clss)
00037 
00038 struct _mDataSource {
00039         mDataSourceHeader(mDataSource)
00040 };
00041 
00042 MGNCS_EXPORT extern mDataSourceClass g_stmDataSourceCls;
00043 
00045 #define NCS_RS_CURSOR_BEGIN 0
00046 #define NCS_RS_CURSOR_CUR   1
00047 #define NCS_RS_CURSOR_END   2
00048 
00049 #define NCS_RS_INSERT_AFTER  0
00050 #define NCS_RS_INSERT_APPEND 1
00051 #define NCS_RS_INSERT_BEFORE 2
00052 
00053 #define NCS_RSE_CURSOR_UPDATE 0x01
00054 #define NCS_RSE_VALUE_UPATED  0x02
00055 #define NCS_RSE_VALUE_CREATE  0x04
00056 #define NCS_RSE_VALUE_REMOVED 0x08
00057 
00058 #define mRecordSetClassHeader(clss, superCls) \
00059         mObjectClassHeader(clss, superCls) \
00060         int (*getFieldCount)(clss*); \
00061         int (*getRecordCount)(clss*); \
00062         int (*getFieldType)(clss*, int filed_idx); \
00063         DWORD (*getCursor)(clss *); \
00064         BOOL  (*setCursor)(clss *, DWORD cursor); \
00065         DWORD (*seekCursor)(clss *, int seek, int offset); \
00066         DWORD (*getField)(clss *, int idx); \
00067         BOOL  (*setField)(clss *, int idx, DWORD value); \
00068         BOOL  (*newRecord)(clss *, int insert_type);  \
00069         BOOL  (*deleteRecord)(clss *); \
00070         BOOL  (*update)(clss *); \
00071         BOOL  (*cancel)(clss *); \
00072         BOOL  (*isEnd)(clss *); \
00073         mBindProp * (*getFieldBind)(clss *, int field_idx, int event_filter, int bp_type); \
00074         mBindProp * (*getCursorBind)(clss *, int bp_type);
00075 
00076 struct _mRecordSetClass{
00077         mRecordSetClassHeader(mRecordSet, mObject)
00078 };
00079 
00080 #define mRecordSetHeader(clss) \
00081         mObjectHeader(clss)
00082 
00083 struct _mRecordSet{
00084         mRecordSetHeader(mRecordSet)
00085 };
00086 
00087 MGNCS_EXPORT extern mRecordSetClass g_stmRecordSetCls;
00088 
00090 // Bind Prop
00091 
00092 typedef struct _mDataBindPropClass mDataBindPropClass;
00093 typedef struct _mDataBindProp mDataBindProp;
00094 
00095 #define mDataBindPropClassHeader(clss, supper) \
00096         mBindPropClassHeader(clss,  supper) \
00097 
00098 struct _mDataBindPropClass{
00099         mDataBindPropClassHeader(mDataBindProp, mBindProp)
00100 };
00101 
00102 MGNCS_EXPORT extern mDataBindPropClass g_stmDataBindPropCls;
00103 
00104 #define mDataBindPropHeader(clss) \
00105         mBindPropHeader(clss) \
00106         unsigned int event_filter:16; \
00107         unsigned int revert:16;
00108 
00109 struct _mDataBindProp {
00110         mDataBindPropHeader(mDataBindProp)
00111 };
00112 
00113 typedef struct _mDataValueBindPropClass mDataValueBindPropClass;
00114 typedef struct _mDataValueBindProp mDataValueBindProp;
00115 
00116 #define mDataValueBindPropClassHeader(clss, super) \
00117         mDataBindPropClassHeader(clss, super)
00118 
00119 struct _mDataValueBindPropClass{
00120         mDataValueBindPropClassHeader(mDataValueBindProp, mDataBindProp)
00121 };
00122 
00123 #define mDataValueBindPropHeader(clss) \
00124         mDataBindPropHeader(clss) \
00125         DWORD *pvalue;
00126 
00127 struct _mDataValueBindProp{
00128         mDataValueBindPropHeader(mDataValueBindProp)
00129 };
00130 
00131 
00132 typedef struct _mDataFieldBindPropClass mDataFieldBindPropClass;
00133 typedef struct _mDataFieldBindProp mDataFieldBindProp;
00134 
00135 #define mDataFieldBindPropClassHeader(clss, super) \
00136         mDataBindPropClassHeader(clss, super)
00137 
00138 struct _mDataFieldBindPropClass {
00139         mDataFieldBindPropClassHeader(mDataFieldBindProp, mDataBindProp)
00140 };
00141 
00142 #define mDataFieldBindPropHeader(clss) \
00143         mDataBindPropHeader(clss) \
00144         mRecordSet * recordSet;
00145 
00146 //user mDataBindProp::revert as field_idx
00147 
00148 struct _mDataFieldBindProp {
00149         mDataFieldBindPropHeader(mDataFieldBindProp)
00150 };
00151 
00152 
00153 MGNCS_EXPORT void ncsRaiseDataSourceBindProps(mObject *obj, int event_filter);
00154 
00155 MGNCS_EXPORT mBindProp * ncsRegisterDataValueBindProp(mDataSource *obj, DWORD *pvalue, int type, int flags, int event_filter);
00156 
00157 MGNCS_EXPORT mBindProp * ncsRegisterDataFieldBindProp(mRecordSet *rs, int field_idx, int flags, int event_filter);
00158 
00159 #define DATA_VAR_PROP(owner, pvalue ,data_type, flags, event_filter) \
00160         ncsRegisterDataValueBindProp((mDataSource*)(owner), (DWORD*)(pvalue), (int)(data_type), (int)(flags), (int)(event_filter));
00161 
00162 #define DATA_FIELD_PROP(rs, field, flags, event_filer) \
00163         ncsRegisterDataFieldBindProp((mRecordSet*)(rs), (int)(field), (int)(flags), (int)(event_filter))
00164 
00165 
00167 // Default DataSource
00168 
00169 BOOL ncsInitDefaultDataSource(void);
00170 //mStaticDataSource
00171 MGNCS_EXPORT extern mDataSource* g_pStaticDS;
00172 
00173 MGNCS_EXPORT BOOL ncsRegisterStaticData(const char* pvalue_path, void ** array, int array_count, int field_count, int filed_width, const unsigned char* field_types);
00174 
00175 MGNCS_EXPORT BOOL ncsRegisterStaticValue(const char* pvalue_path, DWORD value, int type);
00176 #define ncsRegisterStaticString(pvalue_path, str) do{ \
00177         static char _str[] = str; \
00178         ncsRegisterStaticValue(pvalue_path, _str, NCS_BT_STR; \
00179 }while(0)
00180 
00181 
00182 //mTextDataSource
00183 MGNCS_EXPORT mDataSource* ncsCreateTextDataSource(const char* source_file, int spliter, int mode);
00184 
00185 //mEtcDataSource
00186 MGNCS_EXPORT mDataSource* ncsCreateEtcDataSource(const char* etc_file, int mode);
00187 
00188 MGNCS_EXPORT mDataSource* ncsCreateEtcDataSourceByHandle(GHANDLE hEtc, int mode);
00189 
00190 //mSQLiteDataSource
00191 #ifdef _MGNCSDB_SQLITE
00192 MGNCS_EXPORT mDataSource* ncsCreateSQLiteDataSource(const char* sqlite_file, int mode);
00193 #endif
00194 
00196 
00197 
00198 #ifdef __cplusplus
00199 }
00200 #endif
00201 
00202 #endif
00203 
Generated on Fri Jun 10 11:18:06 2011 for New Control Set V1.0.0 API Reference by  doxygen 1.6.3