mGNCS API Reference  v1.2.0
A new control set and a new framework for MiniGUI apps
mtype.h
Go to the documentation of this file.
1 
42 #ifndef MGNCS_TYPE_H
43 #define MGNCS_TYPE_H
44 
45 typedef void* HAUTOPOOL;
46 
47 enum ncsBindingDataTYPE{
48  NCS_BT_INT = 1,
49  NCS_BT_STR,
50  NCS_BT_CHAR,
51  NCS_BT_NUMBER,
52  NCS_BT_MAX
53 };
54 
55 #define SBPE_OK 0
56 #define SBPE_READERROR 1 //psrc cannot read
57 #define SBPE_WRITEERROR 2 //pdest cannot write
58 #define SBPE_MISSMATCH 3 //type miss match
59 
60 typedef void (*NCS_SET_VALUE)(void* self, DWORD dst_v);
61 MGNCS_EXPORT int ncsTransType(DWORD value, int src_type, int dest_type, NCS_SET_VALUE set_value, void *self);
62 
67 MGNCS_EXPORT int ncsTypeToInt(DWORD value, int src_type);
68 
69 #define ncsStrToInt(str) ncsTypeToInt((DWORD)(str), NCS_BT_STR)
70 #define ncsCharToInt(ch) (int)((char)(ch))
71 
72 MGNCS_EXPORT int ncsTypeToChar(DWORD value, int scr_type);
73 
74 static inline int ncsStrToChar(DWORD str) {
75  if(str == 0)
76  return 0;
77  return *((const char*)(str));
78 }
79 
80 #define ncsIntToChar(i) ((char)(i))
81 
85 MGNCS_EXPORT char* ncsTypeToString(DWORD value, int src_type);
86 
91 MGNCS_EXPORT HAUTOPOOL ncsCreateAutoPool(int size);
92 MGNCS_EXPORT void ncsResetAutoPool(HAUTOPOOL hPool);
93 MGNCS_EXPORT void ncsFreeAutoPool(HAUTOPOOL hPool);
94 
95 MGNCS_EXPORT char* ncsTypeToAutoString(DWORD value, int src_type, HAUTOPOOL hAutoPool);
96 
97 #define _BEGIN_AUTO_STR_EX(size) { HAUTOPOOL __local_auto_pool__ = ncsCreateAutoPool(size);
98 #define _BEGIN_AUTO_STR _BEGIN_AUTO_STR_EX(-1)
99 
100 #define _END_AUTO_STR ncsFreeAutoPool(__local_auto_pool__); }
101 
102 #define _RESET_AUTO_STR ncsResetAutoPool(__local_auto_pool__);
103 
104 #define _AUTO_STR(data,src_type) ((char*)ncsTypeToAutoString((data), (src_type), __local_auto_pool__))
105 
106 #define _RET_AUTO_STR do{ ncsFreeAutoPool(__local_auto_pool__); return; }while(0)
107 #define _RETV_AUTO_STR(ret) do { ncsFreeAutoPool(__local_auto_pool__); return (ret); }while(0)
108 
109 #endif
110 
111 
MGNCS_EXPORT char * ncsTypeToString(DWORD value, int src_type)
MGNCS_EXPORT int ncsTypeToInt(DWORD value, int src_type)
MGNCS_EXPORT HAUTOPOOL ncsCreateAutoPool(int size)