00001 00002 #ifndef MGNCS_TYPE_H 00003 #define MGNCS_TYPE_H 00004 00005 typedef void* HAUTOPOOL; 00006 00007 enum ncsBindingDataTYPE{ 00008 NCS_BT_INT = 1, 00009 NCS_BT_STR, 00010 NCS_BT_CHAR, 00011 NCS_BT_NUMBER, 00012 NCS_BT_MAX 00013 }; 00014 00015 #define SBPE_OK 0 00016 #define SBPE_READERROR 1 //psrc cannot read 00017 #define SBPE_WRITEERROR 2 //pdest cannot write 00018 #define SBPE_MISSMATCH 3 //type miss match 00019 00020 typedef void (*NCS_SET_VALUE)(void* self, DWORD dst_v); 00021 MGNCS_EXPORT int ncsTransType(DWORD value, int src_type, int dest_type, NCS_SET_VALUE set_value, void *self); 00022 00027 MGNCS_EXPORT int ncsTypeToInt(DWORD value, int src_type); 00028 00029 #define ncsStrToInt(str) ncsTypeToInt((DWORD)(str), NCS_BT_STR) 00030 #define ncsCharToInt(ch) (int)((char)(ch)) 00031 00032 MGNCS_EXPORT int ncsTypeToChar(DWORD value, int scr_type); 00033 00034 static inline int ncsStrToChar(DWORD str) { 00035 if(str == 0) 00036 return 0; 00037 return *((const char*)(str)); 00038 } 00039 00040 #define ncsIntToChar(i) ((char)(i)) 00041 00045 MGNCS_EXPORT char* ncsTypeToString(DWORD value, int src_type); 00046 00051 MGNCS_EXPORT HAUTOPOOL ncsCreateAutoPool(int size); 00052 MGNCS_EXPORT void ncsResetAutoPool(HAUTOPOOL hPool); 00053 MGNCS_EXPORT void ncsFreeAutoPool(HAUTOPOOL hPool); 00054 00055 MGNCS_EXPORT char* ncsTypeToAutoString(DWORD value, int src_type, HAUTOPOOL hAutoPool); 00056 00057 #define _BEGIN_AUTO_STR_EX(size) { HAUTOPOOL __local_auto_pool__ = ncsCreateAutoPool(size); 00058 #define _BEGIN_AUTO_STR _BEGIN_AUTO_STR_EX(-1) 00059 00060 #define _END_AUTO_STR ncsFreeAutoPool(__local_auto_pool__); } 00061 00062 #define _RESET_AUTO_STR ncsResetAutoPool(__local_auto_pool__); 00063 00064 #define _AUTO_STR(data,src_type) ((char*)ncsTypeToAutoString((data), (src_type), __local_auto_pool__)) 00065 00066 #define _RET_AUTO_STR do{ ncsFreeAutoPool(__local_auto_pool__); return; }while(0) 00067 #define _RETV_AUTO_STR(ret) do { ncsFreeAutoPool(__local_auto_pool__); return (ret); }while(0) 00068 00069 #endif 00070 00071
1.6.3