mGNCS API Reference  v1.5.0
A new control set and a new framework for MiniGUI apps
mtype.h
Go to the documentation of this file.
1 //
3 // IMPORTANT NOTICE
4 //
5 // The following open source license statement does not apply to any
6 // entity in the Exception List published by FMSoft.
7 //
8 // For more information, please visit:
9 //
10 // https://www.fmsoft.cn/exception-list
11 //
13 
54 #ifndef MGNCS_TYPE_H
55 #define MGNCS_TYPE_H
56 
57 typedef void* HAUTOPOOL;
58 
59 enum ncsBindingDataTYPE{
60  NCS_BT_INT = 1,
61  NCS_BT_STR,
62  NCS_BT_CHAR,
63  NCS_BT_NUMBER,
64  NCS_BT_MAX
65 };
66 
67 #define SBPE_OK 0
68 #define SBPE_READERROR 1 //psrc cannot read
69 #define SBPE_WRITEERROR 2 //pdest cannot write
70 #define SBPE_MISSMATCH 3 //type miss match
71 
72 typedef void (*NCS_SET_VALUE)(void* self, DWORD dst_v);
73 MGNCS_EXPORT int ncsTransType(DWORD value, int src_type, int dest_type, NCS_SET_VALUE set_value, void *self);
74 
79 MGNCS_EXPORT int ncsTypeToInt(DWORD value, int src_type);
80 
81 #define ncsStrToInt(str) ncsTypeToInt((DWORD)(str), NCS_BT_STR)
82 #define ncsCharToInt(ch) (int)((char)(ch))
83 
84 MGNCS_EXPORT int ncsTypeToChar(DWORD value, int scr_type);
85 
86 static inline int ncsStrToChar(DWORD str) {
87  if(str == 0)
88  return 0;
89  return *((const char*)(str));
90 }
91 
92 #define ncsIntToChar(i) ((char)(i))
93 
97 MGNCS_EXPORT char* ncsTypeToString(DWORD value, int src_type);
98 
103 MGNCS_EXPORT HAUTOPOOL ncsCreateAutoPool(int size);
104 MGNCS_EXPORT void ncsResetAutoPool(HAUTOPOOL hPool);
105 MGNCS_EXPORT void ncsFreeAutoPool(HAUTOPOOL hPool);
106 
107 MGNCS_EXPORT char* ncsTypeToAutoString(DWORD value, int src_type, HAUTOPOOL hAutoPool);
108 
109 #define _BEGIN_AUTO_STR_EX(size) { HAUTOPOOL __local_auto_pool__ = ncsCreateAutoPool(size);
110 #define _BEGIN_AUTO_STR _BEGIN_AUTO_STR_EX(-1)
111 
112 #define _END_AUTO_STR ncsFreeAutoPool(__local_auto_pool__); }
113 
114 #define _RESET_AUTO_STR ncsResetAutoPool(__local_auto_pool__);
115 
116 #define _AUTO_STR(data,src_type) ((char*)ncsTypeToAutoString((data), (src_type), __local_auto_pool__))
117 
118 #define _RET_AUTO_STR do{ ncsFreeAutoPool(__local_auto_pool__); return; }while(0)
119 #define _RETV_AUTO_STR(ret) do { ncsFreeAutoPool(__local_auto_pool__); return (ret); }while(0)
120 
121 #endif
122 
123 
ncsTypeToString
MGNCS_EXPORT char * ncsTypeToString(DWORD value, int src_type)
ncsTypeToInt
MGNCS_EXPORT int ncsTypeToInt(DWORD value, int src_type)
ncsCreateAutoPool
MGNCS_EXPORT HAUTOPOOL ncsCreateAutoPool(int size)