transactd 2.4.5 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CMakeLists.txt +1 -1
- data/README-JA.md +52 -529
- data/README.md +52 -523
- data/bin/common/tdclc_32_3_0.dll +0 -0
- data/bin/common/tdclc_64_3_0.dll +0 -0
- data/build/common/system.cmake +2 -1
- data/build/common/transactd_cl_common.cmake +3 -6
- data/build/swig/ruby/ruby.swg +85 -28
- data/build/swig/ruby/tdclrb_wrap.cpp +3195 -1578
- data/build/swig/tdcl.i +161 -5
- data/build/tdclc/CMakeLists.txt +1 -0
- data/build/tdclc/tdclc.cbproj +7 -1
- data/build/tdclc/tdclc.rc +4 -4
- data/build/tdclcpp/tdclcpp.rc +4 -4
- data/build/tdclcpp/tdclcpp_bc.cbproj +2 -5
- data/build/tdclrb/tdclrb.rc +4 -4
- data/source/bzs/db/blobStructs.h +1 -1
- data/source/bzs/db/engine/mysql/database.cpp +199 -74
- data/source/bzs/db/engine/mysql/database.h +47 -18
- data/source/bzs/db/engine/mysql/dbManager.cpp +1 -0
- data/source/bzs/db/engine/mysql/mysqlInternal.h +32 -8
- data/source/bzs/db/protocol/tdap/btrDate.cpp +110 -75
- data/source/bzs/db/protocol/tdap/btrDate.h +46 -21
- data/source/bzs/db/protocol/tdap/client/activeTable.cpp +18 -18
- data/source/bzs/db/protocol/tdap/client/activeTable.h +25 -25
- data/source/bzs/db/protocol/tdap/client/activeTableImple.h +10 -4
- data/source/bzs/db/protocol/tdap/client/client.cpp +6 -5
- data/source/bzs/db/protocol/tdap/client/client.h +82 -15
- data/source/bzs/db/protocol/tdap/client/database.cpp +531 -142
- data/source/bzs/db/protocol/tdap/client/database.h +19 -6
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +461 -408
- data/source/bzs/db/protocol/tdap/client/dbDef.h +11 -17
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +61 -13
- data/source/bzs/db/protocol/tdap/client/field.cpp +1592 -1398
- data/source/bzs/db/protocol/tdap/client/field.h +110 -121
- data/source/bzs/db/protocol/tdap/client/fields.h +40 -10
- data/source/bzs/db/protocol/tdap/client/filter.h +69 -55
- data/source/bzs/db/protocol/tdap/client/groupQuery.cpp +296 -164
- data/source/bzs/db/protocol/tdap/client/groupQuery.h +77 -25
- data/source/bzs/db/protocol/tdap/client/memRecord.cpp +31 -13
- data/source/bzs/db/protocol/tdap/client/memRecord.h +31 -21
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +1 -1
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +4 -1
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +69 -24
- data/source/bzs/db/protocol/tdap/client/nsTable.h +3 -1
- data/source/bzs/db/protocol/tdap/client/recordset.cpp +1 -0
- data/source/bzs/db/protocol/tdap/client/recordsetImple.h +46 -27
- data/source/bzs/db/protocol/tdap/client/request.h +2 -1
- data/source/bzs/db/protocol/tdap/client/serializer.cpp +44 -9
- data/source/bzs/db/protocol/tdap/client/serializer.h +1 -1
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +182 -76
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +23 -12
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +8 -10
- data/source/bzs/db/protocol/tdap/client/table.cpp +172 -93
- data/source/bzs/db/protocol/tdap/client/table.h +112 -37
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +17 -0
- data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +0 -1
- data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +0 -2
- data/source/bzs/db/protocol/tdap/client/trdormapi.h +1 -1
- data/source/bzs/db/protocol/tdap/fieldComp.h +698 -14
- data/source/bzs/db/protocol/tdap/myDateTime.cpp +723 -307
- data/source/bzs/db/protocol/tdap/myDateTime.h +294 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +164 -54
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +6 -3
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +133 -550
- data/source/bzs/db/protocol/tdap/mysql/request.h +6 -5
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +217 -82
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +1 -1
- data/source/bzs/db/protocol/tdap/tdapRequest.h +4 -9
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +808 -17
- data/source/bzs/db/protocol/tdap/tdapSchema.h +656 -164
- data/source/bzs/db/protocol/tdap/tdapcapi.h +130 -28
- data/source/bzs/db/protocol/tdap/uri.h +40 -32
- data/source/bzs/db/transactd/connManager.cpp +1 -1
- data/source/bzs/db/transactd/transactd.cpp +7 -0
- data/source/bzs/env/compiler.h +107 -94
- data/source/bzs/env/crosscompile.cpp +24 -12
- data/source/bzs/env/crosscompile.h +75 -6
- data/source/bzs/env/mbcswchrLinux.cpp +2 -2
- data/source/bzs/env/tcharMinGW.h +4 -0
- data/source/bzs/example/changeSchema.cpp +22 -17
- data/source/bzs/example/queryData.cpp +4 -0
- data/source/bzs/netsvc/client/iconnection.h +3 -1
- data/source/bzs/netsvc/client/tcpClient.h +10 -3
- data/source/bzs/rtl/stringBuffers.cpp +7 -0
- data/source/bzs/test/tdclatl/bench_query_atl.js +6 -0
- data/source/bzs/test/tdclatl/bench_tdclatl.js +8 -1
- data/source/bzs/test/tdclatl/test_query_atl.js +22 -2
- data/source/bzs/test/tdclatl/test_v3.js +1017 -0
- data/source/bzs/test/tdclphp/transactd_Test.php +55 -21
- data/source/bzs/test/tdclphp/transactd_datetime_Test.php +0 -5
- data/source/bzs/test/tdclphp/transactd_pool_Test.php +2 -0
- data/source/bzs/test/tdclphp/transactd_v3_Test.php +743 -0
- data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +0 -5
- data/source/bzs/test/tdclrb/transactd_pool_spec.rb +2 -0
- data/source/bzs/test/tdclrb/transactd_spec.rb +39 -16
- data/source/bzs/test/tdclrb/transactd_v3_spec.rb +748 -0
- data/source/bzs/test/transactdBench/transactdBench.cpp +55 -58
- data/source/bzs/test/transactdBench/transactdBench2.cpp +1 -3
- data/source/bzs/test/trdclengn/testField.h +3305 -0
- data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +1050 -0
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +112 -190
- data/source/bzs/test/trdclengn/testbase.h +137 -0
- data/source/global/ormsrcgen/srcgen.cpp +23 -12
- data/source/global/ormsrcgen/template/ormDataClass_template.h +2 -0
- data/source/global/querystmts/querystmts.cpp +2 -3
- data/source/global/tdclatl/Bitset.cpp +38 -0
- data/source/global/tdclatl/Bitset.h +63 -0
- data/source/global/tdclatl/Database.cpp +59 -18
- data/source/global/tdclatl/Database.h +7 -4
- data/source/global/tdclatl/DbDef.cpp +6 -6
- data/source/global/tdclatl/DbDef.h +2 -1
- data/source/global/tdclatl/Field.cpp +112 -0
- data/source/global/tdclatl/Field.h +19 -5
- data/source/global/tdclatl/FieldDef.cpp +137 -16
- data/source/global/tdclatl/FieldDef.h +18 -2
- data/source/global/tdclatl/FieldDefs.cpp +54 -1
- data/source/global/tdclatl/FieldDefs.h +3 -0
- data/source/global/tdclatl/GroupQuery.cpp +8 -8
- data/source/global/tdclatl/QueryBase.cpp +65 -0
- data/source/global/tdclatl/QueryBase.h +10 -0
- data/source/global/tdclatl/Record.cpp +33 -2
- data/source/global/tdclatl/Record.h +3 -1
- data/source/global/tdclatl/RecordsetQuery.cpp +42 -0
- data/source/global/tdclatl/RecordsetQuery.h +8 -0
- data/source/global/tdclatl/Table.cpp +127 -3
- data/source/global/tdclatl/Table.h +10 -1
- data/source/global/tdclatl/TableDef.cpp +41 -8
- data/source/global/tdclatl/TableDef.h +7 -2
- data/source/global/tdclatl/activeTable.cpp +40 -71
- data/source/global/tdclatl/resource.h +0 -0
- data/source/global/tdclatl/tdclatl.idl +222 -28
- data/source/linux/tchar.h +100 -96
- data/transactd.gemspec +2 -2
- metadata +13 -11
- data/BUILD_UNIX-JA.md +0 -161
- data/BUILD_WIN-JA.md +0 -326
- data/README_ORMSRCGEN-JA.md +0 -115
- data/README_ORMSRCGEN.md +0 -118
- data/RELEASE_NOTE-JA.md +0 -356
- data/RELEASE_NOTE.md +0 -360
- data/bin/common/tdclc_32_2_4.dll +0 -0
- data/bin/common/tdclc_64_2_4.dll +0 -0
- data/source/bzs/test/trdclengn/test_blob.cpp +0 -375
@@ -23,10 +23,145 @@
|
|
23
23
|
#include <algorithm>
|
24
24
|
#include <string.h>
|
25
25
|
|
26
|
+
|
27
|
+
inline __int64 changeEndian2(__int64 v)
|
28
|
+
{
|
29
|
+
__int64 ret = 0;
|
30
|
+
char* l = (char*)&ret;
|
31
|
+
char* r = (char*)&v;
|
32
|
+
l[0] = r[1];
|
33
|
+
l[1] = r[0];
|
34
|
+
return ret;
|
35
|
+
}
|
36
|
+
|
37
|
+
inline __int64 changeEndian3(__int64 v)
|
38
|
+
{
|
39
|
+
__int64 ret = 0;
|
40
|
+
char* l = (char*)&ret;
|
41
|
+
char* r = (char*)&v;
|
42
|
+
l[0] = r[2];
|
43
|
+
l[1] = r[1];
|
44
|
+
l[2] = r[0];
|
45
|
+
return ret;
|
46
|
+
}
|
47
|
+
|
48
|
+
inline __int64 changeEndian4(__int64 v)
|
49
|
+
{
|
50
|
+
__int64 ret = 0;
|
51
|
+
char* l = (char*)&ret;
|
52
|
+
char* r = (char*)&v;
|
53
|
+
l[0] = r[3];
|
54
|
+
l[1] = r[2];
|
55
|
+
l[2] = r[1];
|
56
|
+
l[3] = r[0];
|
57
|
+
return ret;
|
58
|
+
}
|
59
|
+
|
60
|
+
inline __int64 changeEndian5(__int64 v)
|
61
|
+
{
|
62
|
+
__int64 ret = 0;
|
63
|
+
char* l = (char*)&ret;
|
64
|
+
char* r = (char*)&v;
|
65
|
+
l[0] = r[4];
|
66
|
+
l[1] = r[3];
|
67
|
+
l[2] = r[2];
|
68
|
+
l[3] = r[1];
|
69
|
+
l[4] = r[0];
|
70
|
+
return ret;
|
71
|
+
}
|
72
|
+
|
73
|
+
inline __int64 changeEndian6(__int64 v)
|
74
|
+
{
|
75
|
+
__int64 ret = 0;
|
76
|
+
char* l = (char*)&ret;
|
77
|
+
char* r = (char*)&v;
|
78
|
+
l[0] = r[5];
|
79
|
+
l[1] = r[4];
|
80
|
+
l[2] = r[3];
|
81
|
+
l[3] = r[2];
|
82
|
+
l[4] = r[1];
|
83
|
+
l[5] = r[0];
|
84
|
+
return ret;
|
85
|
+
}
|
86
|
+
|
87
|
+
inline __int64 changeEndian7(__int64 v)
|
88
|
+
{
|
89
|
+
__int64 ret = 0;
|
90
|
+
char* l = (char*)&ret;
|
91
|
+
char* r = (char*)&v;
|
92
|
+
l[0] = r[6];
|
93
|
+
l[1] = r[5];
|
94
|
+
l[2] = r[4];
|
95
|
+
l[3] = r[3];
|
96
|
+
l[4] = r[2];
|
97
|
+
l[5] = r[1];
|
98
|
+
l[6] = r[0];
|
99
|
+
return ret;
|
100
|
+
}
|
101
|
+
|
102
|
+
inline __int64 changeEndian8(__int64 v)
|
103
|
+
{
|
104
|
+
__int64 ret = 0;
|
105
|
+
char* l = (char*)&ret;
|
106
|
+
char* r = (char*)&v;
|
107
|
+
l[0] = r[7];
|
108
|
+
l[1] = r[6];
|
109
|
+
l[2] = r[5];
|
110
|
+
l[3] = r[4];
|
111
|
+
l[4] = r[3];
|
112
|
+
l[5] = r[2];
|
113
|
+
l[6] = r[1];
|
114
|
+
l[7] = r[0];
|
115
|
+
return ret;
|
116
|
+
}
|
117
|
+
|
118
|
+
inline __int64 changeEndian(__int64 v, int len)
|
119
|
+
{
|
120
|
+
switch(len)
|
121
|
+
{
|
122
|
+
case 1: return v;
|
123
|
+
case 2: return changeEndian2(v);
|
124
|
+
case 3: return changeEndian3(v);
|
125
|
+
case 4: return changeEndian4(v);
|
126
|
+
case 5: return changeEndian5(v);
|
127
|
+
case 6: return changeEndian6(v);
|
128
|
+
case 7: return changeEndian7(v);
|
129
|
+
case 8: return changeEndian8(v);
|
130
|
+
}
|
131
|
+
return v;
|
132
|
+
}
|
133
|
+
|
134
|
+
inline int int24toInt(const char* p)
|
135
|
+
{
|
136
|
+
return ((*((int*)p) & 0xFFFFFF) << 8) / 0x100;
|
137
|
+
}
|
138
|
+
|
139
|
+
inline unsigned int int24toUint(const char* p)
|
140
|
+
{
|
141
|
+
return *((unsigned int*)p) & 0xFFFFFF;
|
142
|
+
}
|
143
|
+
|
144
|
+
inline __int64 myBittoInt64(const char* p, int len)
|
145
|
+
{
|
146
|
+
__int64 v = 0;
|
147
|
+
memcpy(&v, p, len);
|
148
|
+
return changeEndian8(v);
|
149
|
+
}
|
150
|
+
|
151
|
+
inline void storeInt24(int v, char* p)
|
152
|
+
{
|
153
|
+
memcpy(p, &v, 3);
|
154
|
+
}
|
155
|
+
|
156
|
+
inline void storeUint24(unsigned int v, char* p)
|
157
|
+
{
|
158
|
+
memcpy(p, &v, 3);
|
159
|
+
}
|
160
|
+
|
26
161
|
inline int compareUint24(const char* l, const char* r)
|
27
162
|
{
|
28
|
-
unsigned int lv =
|
29
|
-
unsigned int rv =
|
163
|
+
unsigned int lv = int24toUint(l);
|
164
|
+
unsigned int rv = int24toUint(r);;
|
30
165
|
if (lv < rv)
|
31
166
|
return -1;
|
32
167
|
if (lv > rv)
|
@@ -36,8 +171,8 @@ inline int compareUint24(const char* l, const char* r)
|
|
36
171
|
|
37
172
|
inline int compareInt24(const char* l, const char* r)
|
38
173
|
{
|
39
|
-
int lv = (
|
40
|
-
int rv = (
|
174
|
+
int lv = int24toInt(l);
|
175
|
+
int rv = int24toInt(r);
|
41
176
|
|
42
177
|
if (lv < rv)
|
43
178
|
return -1;
|
@@ -58,7 +193,12 @@ template <class T> inline int compare(const char* l, const char* r)
|
|
58
193
|
template <class T> inline int bitMask(const char* l, const char* r)
|
59
194
|
{
|
60
195
|
T v = *((T*)l) & *((T*)r);
|
61
|
-
|
196
|
+
v = (*((T*)r) - v);
|
197
|
+
/*
|
198
|
+
When T is __int64 then v is incoreect value.
|
199
|
+
Because return size is int.
|
200
|
+
*/
|
201
|
+
return (v > 0) ? 1 : ((v < 0) ? -1 : 0);
|
62
202
|
}
|
63
203
|
|
64
204
|
template <class T> inline int compare(T l, T r)
|
@@ -71,30 +211,30 @@ template <class T> inline int compare(T l, T r)
|
|
71
211
|
}
|
72
212
|
|
73
213
|
template <class T>
|
74
|
-
inline int compareVartype(const char* l, const char* r, bool bin,
|
214
|
+
inline int compareVartype(const char* l, const char* r, bool bin, bool all, bool incase)
|
75
215
|
{
|
76
216
|
int llen = (*(T*)l);
|
77
217
|
int rlen = (*(T*)r);
|
78
218
|
int tmp = std::min<int>(llen, rlen);
|
79
|
-
if (
|
219
|
+
if (incase)
|
80
220
|
tmp = _strnicmp(l + sizeof(T), r + sizeof(T), tmp);
|
81
221
|
else if (bin)
|
82
222
|
tmp = memcmp(l + sizeof(T), r + sizeof(T), tmp);
|
83
223
|
else
|
84
224
|
tmp = strncmp(l + sizeof(T), r + sizeof(T), tmp);
|
85
225
|
|
86
|
-
if (
|
226
|
+
if (all)
|
87
227
|
return (tmp == 0) ? compare<int>(llen, rlen) : tmp; // match complete
|
88
228
|
return (tmp == 0 && (llen < rlen)) ? -1 : tmp; // match a part
|
89
229
|
}
|
90
230
|
|
91
231
|
template <class T>
|
92
|
-
inline int compareWvartype(const char* l, const char* r, bool bin,
|
232
|
+
inline int compareWvartype(const char* l, const char* r, bool bin, bool all, bool incase)
|
93
233
|
{
|
94
234
|
int llen = (*(T*)l) / sizeof(char16_t);
|
95
235
|
int rlen = (*(T*)r) / sizeof(char16_t);
|
96
236
|
int tmp = std::min<int>(llen, rlen);
|
97
|
-
if (
|
237
|
+
if (incase)
|
98
238
|
tmp = wcsnicmp16((char16_t*)(l + sizeof(T)), (char16_t*)(r + sizeof(T)),
|
99
239
|
tmp);
|
100
240
|
else if (bin)
|
@@ -103,12 +243,12 @@ inline int compareWvartype(const char* l, const char* r, bool bin, char logType)
|
|
103
243
|
else
|
104
244
|
tmp = wcsncmp16((char16_t*)(l + sizeof(T)), (char16_t*)(r + sizeof(T)),
|
105
245
|
tmp);
|
106
|
-
if (
|
246
|
+
if (all)
|
107
247
|
return (tmp == 0) ? compare<int>(llen, rlen) : tmp; // match complete
|
108
248
|
return (tmp == 0 && (llen < rlen)) ? -1 : tmp; // match a part
|
109
249
|
}
|
110
250
|
|
111
|
-
inline int compareBlobType(const char* l, const char* r, bool bin,
|
251
|
+
inline int compareBlobType(const char* l, const char* r, bool bin, bool all, bool incase,
|
112
252
|
int sizeByte)
|
113
253
|
{
|
114
254
|
int llen = 0;
|
@@ -118,16 +258,560 @@ inline int compareBlobType(const char* l, const char* r, bool bin, char logType,
|
|
118
258
|
int tmp = std::min<int>(llen, rlen);
|
119
259
|
const char* lptr = *((const char**)(l + sizeByte));
|
120
260
|
const char* rptr = r + sizeByte;
|
121
|
-
if (
|
261
|
+
if (incase)
|
122
262
|
tmp = _strnicmp(lptr, rptr, tmp);
|
123
263
|
else if (bin)
|
124
264
|
tmp = memcmp(lptr, rptr, tmp);
|
125
265
|
else
|
126
266
|
tmp = strncmp(lptr, rptr, tmp);
|
127
267
|
|
128
|
-
if (
|
268
|
+
if (all)
|
129
269
|
return (tmp == 0) ? compare<int>(llen, rlen) : tmp;
|
130
270
|
return (tmp == 0 && (llen < rlen)) ? -1 : tmp;
|
131
271
|
}
|
132
272
|
|
273
|
+
/* int nullComp(bool lnull, bool rnull, char log)
|
274
|
+
|
275
|
+
lnull rnull log ret
|
276
|
+
-----------------------------------------------
|
277
|
+
true true isNull 0
|
278
|
+
true true isNotNull -1
|
279
|
+
true false 0 -1
|
280
|
+
false true isNull 1
|
281
|
+
false true isNotNull 0
|
282
|
+
false false 0 2
|
283
|
+
-----------------------------------------------
|
284
|
+
|
285
|
+
real value example
|
286
|
+
|
287
|
+
lval rval ret
|
288
|
+
-----------------------------------------------
|
289
|
+
NULL isNull 0
|
290
|
+
NULL isNotNull -1
|
291
|
+
NULL 2 -1
|
292
|
+
1 isNull 1
|
293
|
+
1 isNotNull 0
|
294
|
+
1 2 2
|
295
|
+
-----------------------------------------------
|
296
|
+
*/
|
297
|
+
inline int nullComp(bool lnull, bool rnull, char log)
|
298
|
+
{
|
299
|
+
if (lnull)
|
300
|
+
return (log == eIsNull) ? 0 : -1;
|
301
|
+
else if (rnull)
|
302
|
+
return (log == eIsNull) ? 1 : 0;
|
303
|
+
return 2;
|
304
|
+
}
|
305
|
+
|
306
|
+
template <class T>
|
307
|
+
inline int compBitAnd(const char* l, const char* r, int len)
|
308
|
+
{
|
309
|
+
return bitMask<T>(l, r);
|
310
|
+
}
|
311
|
+
|
312
|
+
inline int compBitAnd24(const char* l, const char* r, int len)
|
313
|
+
{
|
314
|
+
int lv = int24toInt(l);
|
315
|
+
int rv = int24toInt(r);
|
316
|
+
return bitMask<int>((const char*)&lv, (const char*)&rv);
|
317
|
+
}
|
318
|
+
|
319
|
+
inline int compBitAnd64(const char* l, const char* r, int len)
|
320
|
+
{
|
321
|
+
__int64 lv = 0;
|
322
|
+
__int64 rv = 0;
|
323
|
+
memcpy(&lv, l, len);
|
324
|
+
memcpy(&rv, r, len);
|
325
|
+
return bitMask<__int64>((const char*)&lv, (const char*)&rv);
|
326
|
+
}
|
327
|
+
|
328
|
+
template <class T>
|
329
|
+
inline int compNumber(const char* l, const char* r, int len)
|
330
|
+
{
|
331
|
+
return compare<T>(l, r);
|
332
|
+
}
|
333
|
+
|
334
|
+
inline int compNumber24(const char* l, const char* r, int len)
|
335
|
+
{
|
336
|
+
return compareInt24(l, r);
|
337
|
+
}
|
338
|
+
|
339
|
+
inline int compNumberU24(const char* l, const char* r, int len)
|
340
|
+
{
|
341
|
+
return compareUint24(l, r);
|
342
|
+
}
|
343
|
+
|
344
|
+
inline int compMem(const char* l, const char* r, int len)
|
345
|
+
{
|
346
|
+
return memcmp(l, r, len);
|
347
|
+
}
|
348
|
+
|
349
|
+
inline int compString(const char* l, const char* r, int len)
|
350
|
+
{
|
351
|
+
return strncmp(l, r, len);
|
352
|
+
}
|
353
|
+
|
354
|
+
inline int compiString(const char* l, const char* r, int len)
|
355
|
+
{
|
356
|
+
return _strnicmp(l, r, len);
|
357
|
+
}
|
358
|
+
|
359
|
+
inline int compWString(const char* l, const char* r, int len)
|
360
|
+
{
|
361
|
+
return wcsncmp16((char16_t*)l, (char16_t*)r, len/2);
|
362
|
+
}
|
363
|
+
|
364
|
+
inline int compiWString(const char* l, const char* r, int len)
|
365
|
+
{
|
366
|
+
return wcsnicmp16((char16_t*)l, (char16_t*)r, len/2);
|
367
|
+
}
|
368
|
+
|
369
|
+
#define T_BIN true
|
370
|
+
#define T_STR false
|
371
|
+
|
372
|
+
#define T_INCASE true
|
373
|
+
#define T_CASE false
|
374
|
+
|
375
|
+
#define T_CMP_ALL true
|
376
|
+
#define T_CMP_PART false
|
377
|
+
|
378
|
+
|
379
|
+
template <class T, bool all>
|
380
|
+
inline int compVarString(const char* l, const char* r, int len)
|
381
|
+
{
|
382
|
+
return compareVartype<T>(l, r, T_STR, all, T_CASE);
|
383
|
+
}
|
384
|
+
|
385
|
+
template <class T, bool all>
|
386
|
+
inline int compVarString_bin(const char* l, const char* r, int len)
|
387
|
+
{
|
388
|
+
return compareVartype<T>(l, r, T_BIN, all, T_CASE);
|
389
|
+
}
|
390
|
+
template <class T, bool all>
|
391
|
+
inline int compVarString_i(const char* l, const char* r, int len)
|
392
|
+
{
|
393
|
+
return compareVartype<T>(l, r, T_STR, all, T_INCASE);
|
394
|
+
}
|
395
|
+
|
396
|
+
template <class T, bool all>
|
397
|
+
inline int compVarString_bin_i(const char* l, const char* r, int len)
|
398
|
+
{
|
399
|
+
return compareVartype<T>(l, r, T_BIN, all, T_INCASE);
|
400
|
+
}
|
401
|
+
|
402
|
+
template <class T, bool all>
|
403
|
+
inline int compWVarString(const char* l, const char* r, int len)
|
404
|
+
{
|
405
|
+
return compareWvartype<T>(l, r, T_STR, all, T_CASE);
|
406
|
+
}
|
407
|
+
|
408
|
+
template <class T, bool all>
|
409
|
+
inline int compWVarString_bin(const char* l, const char* r, int len)
|
410
|
+
{
|
411
|
+
return compareWvartype<T>(l, r, T_BIN, all, T_CASE);
|
412
|
+
}
|
413
|
+
|
414
|
+
template <class T, bool all>
|
415
|
+
inline int compWVarString_i(const char* l, const char* r, int len)
|
416
|
+
{
|
417
|
+
return compareWvartype<T>(l, r, T_STR, all, T_INCASE);
|
418
|
+
}
|
419
|
+
|
420
|
+
template <class T, bool all>
|
421
|
+
inline int compWVarString_bin_i(const char* l, const char* r, int len)
|
422
|
+
{
|
423
|
+
return compareWvartype<T>(l, r, T_BIN, all, T_INCASE);
|
424
|
+
}
|
425
|
+
|
426
|
+
template <int sizeByte, bool all>
|
427
|
+
inline int compBlob(const char* l, const char* r, int len)
|
428
|
+
{
|
429
|
+
return compareBlobType(l, r, T_STR, all, T_CASE, sizeByte);
|
430
|
+
}
|
431
|
+
|
432
|
+
template <int sizeByte, bool all>
|
433
|
+
inline int compBlob_bin(const char* l, const char* r, int len)
|
434
|
+
{
|
435
|
+
return compareBlobType(l, r, T_BIN, all, T_CASE, sizeByte);
|
436
|
+
}
|
437
|
+
|
438
|
+
template <int sizeByte, bool all>
|
439
|
+
inline int compBlob_i(const char* l, const char* r, int len)
|
440
|
+
{
|
441
|
+
return compareBlobType(l, r, T_STR, all, T_INCASE, sizeByte);
|
442
|
+
}
|
443
|
+
|
444
|
+
template <int sizeByte, bool all>
|
445
|
+
inline int compBlob_bin_i(const char* l, const char* r, int len)
|
446
|
+
{
|
447
|
+
return compareBlobType(l, r, T_BIN, all, T_INCASE, sizeByte);
|
448
|
+
}
|
449
|
+
|
450
|
+
|
451
|
+
typedef int (*comp1Func)(const char* l, const char* r,int len);
|
452
|
+
|
453
|
+
typedef bool (*judgeFunc)(int);
|
454
|
+
|
455
|
+
inline comp1Func getCompFunc(uchar_td type, ushort_td len, char logType, int sizeByte)
|
456
|
+
{
|
457
|
+
bool compAll = (logType & CMPLOGICAL_VAR_COMP_ALL) != 0;
|
458
|
+
bool incase = (logType & CMPLOGICAL_CASEINSENSITIVE) != 0;
|
459
|
+
switch (type)
|
460
|
+
{
|
461
|
+
case ft_integer:
|
462
|
+
case ft_autoinc:
|
463
|
+
case ft_currency:
|
464
|
+
{
|
465
|
+
if (logType & (char)eBitAnd)
|
466
|
+
{
|
467
|
+
switch (len)
|
468
|
+
{
|
469
|
+
case 1:
|
470
|
+
return &compBitAnd<char>;
|
471
|
+
case 2:
|
472
|
+
return &compBitAnd<short>;
|
473
|
+
case 3:
|
474
|
+
return &compBitAnd24;
|
475
|
+
case 4:
|
476
|
+
return &compBitAnd<int>;
|
477
|
+
case 8:
|
478
|
+
return &compBitAnd<__int64>;
|
479
|
+
}
|
480
|
+
}else
|
481
|
+
{
|
482
|
+
switch (len)
|
483
|
+
{
|
484
|
+
case 1:
|
485
|
+
return &compNumber<char>;
|
486
|
+
case 2:
|
487
|
+
return &compNumber<short>;
|
488
|
+
case 3:
|
489
|
+
return &compNumber24;
|
490
|
+
case 4:
|
491
|
+
return &compNumber<int>;
|
492
|
+
case 8:
|
493
|
+
return &compNumber<__int64>;
|
494
|
+
}
|
495
|
+
}
|
496
|
+
}
|
497
|
+
case ft_mychar:
|
498
|
+
case ft_string:
|
499
|
+
if (incase)
|
500
|
+
return &compiString;
|
501
|
+
return &compMem;
|
502
|
+
case ft_zstring:
|
503
|
+
case ft_note:
|
504
|
+
if (incase)
|
505
|
+
return &compiString;
|
506
|
+
return &compString;
|
507
|
+
case ft_logical:
|
508
|
+
case ft_uinteger:
|
509
|
+
case ft_autoIncUnsigned:
|
510
|
+
case ft_date:
|
511
|
+
case ft_time:
|
512
|
+
case ft_timestamp:
|
513
|
+
case ft_myyear:
|
514
|
+
case ft_mydate:
|
515
|
+
case ft_mytime_num_cmp:
|
516
|
+
case ft_mydatetime_num_cmp:
|
517
|
+
case ft_mytimestamp_num_cmp:
|
518
|
+
case ft_set:
|
519
|
+
case ft_enum:
|
520
|
+
{
|
521
|
+
if (logType & (char)eBitAnd)
|
522
|
+
{
|
523
|
+
switch (len)
|
524
|
+
{
|
525
|
+
case 1:
|
526
|
+
return &compBitAnd<char>;
|
527
|
+
case 2:
|
528
|
+
return &compBitAnd<short>;
|
529
|
+
case 3:
|
530
|
+
return &compBitAnd24;
|
531
|
+
case 4:
|
532
|
+
return &compBitAnd<int>;
|
533
|
+
case 8:
|
534
|
+
return &compBitAnd<__int64>;
|
535
|
+
}
|
536
|
+
}else
|
537
|
+
{
|
538
|
+
switch (len)
|
539
|
+
{
|
540
|
+
case 1:
|
541
|
+
return &compNumber<unsigned char>;
|
542
|
+
case 2:
|
543
|
+
return &compNumber<unsigned short>;
|
544
|
+
case 3:
|
545
|
+
return &compNumberU24;
|
546
|
+
case 4:
|
547
|
+
return &compNumber<unsigned int>;
|
548
|
+
case 8:
|
549
|
+
return &compNumber<unsigned __int64>;
|
550
|
+
}
|
551
|
+
}
|
552
|
+
}
|
553
|
+
case ft_bit:
|
554
|
+
if (logType & (char)eBitAnd)
|
555
|
+
return &compBitAnd64;
|
556
|
+
return &compMem;
|
557
|
+
case ft_mytime:
|
558
|
+
case ft_mydatetime:
|
559
|
+
case ft_mytimestamp:
|
560
|
+
case ft_mydecimal:
|
561
|
+
return &compMem;
|
562
|
+
case ft_float:
|
563
|
+
switch (len)
|
564
|
+
{
|
565
|
+
case 4:
|
566
|
+
return &compNumber<float>;
|
567
|
+
case 8:
|
568
|
+
return &compNumber<double>;
|
569
|
+
}
|
570
|
+
case ft_mywchar:
|
571
|
+
case ft_wstring:
|
572
|
+
case ft_wzstring:
|
573
|
+
if (incase)
|
574
|
+
return &compiWString;
|
575
|
+
if ((type == ft_wstring) || (type == ft_mywchar))
|
576
|
+
return &compMem;
|
577
|
+
return &compWString;
|
578
|
+
case ft_lstring:
|
579
|
+
case ft_myvarchar:
|
580
|
+
if (sizeByte == 1)
|
581
|
+
{
|
582
|
+
if (incase)
|
583
|
+
{
|
584
|
+
if (compAll)
|
585
|
+
return &compVarString_i<unsigned char, T_CMP_ALL>;
|
586
|
+
return &compVarString_i<unsigned char, T_CMP_PART>;
|
587
|
+
}else
|
588
|
+
{
|
589
|
+
if (compAll)
|
590
|
+
return &compVarString<unsigned char, T_CMP_ALL>;
|
591
|
+
return &compVarString<unsigned char, T_CMP_PART>;
|
592
|
+
}
|
593
|
+
}
|
594
|
+
if (incase)
|
595
|
+
{
|
596
|
+
if (compAll)
|
597
|
+
return &compVarString_i<unsigned short, T_CMP_ALL>;
|
598
|
+
return &compVarString_i<unsigned short, T_CMP_PART>;
|
599
|
+
}
|
600
|
+
if (compAll)
|
601
|
+
return &compVarString<unsigned short, T_CMP_ALL>;
|
602
|
+
return &compVarString<unsigned short, T_CMP_PART>;
|
603
|
+
case ft_myvarbinary:
|
604
|
+
if (sizeByte == 1)
|
605
|
+
{
|
606
|
+
if (incase)
|
607
|
+
{
|
608
|
+
if (compAll)
|
609
|
+
return &compVarString_bin_i<unsigned char, T_CMP_ALL>;
|
610
|
+
return &compVarString_bin_i<unsigned char, T_CMP_PART>;
|
611
|
+
}
|
612
|
+
if (compAll)
|
613
|
+
return &compVarString_bin<unsigned char, T_CMP_ALL>;
|
614
|
+
return &compVarString_bin<unsigned char, T_CMP_PART>;
|
615
|
+
}
|
616
|
+
if (incase)
|
617
|
+
{
|
618
|
+
if (compAll)
|
619
|
+
return &compVarString_bin_i<unsigned short, T_CMP_ALL>;
|
620
|
+
return &compVarString_bin_i<unsigned short, T_CMP_PART>;
|
621
|
+
}
|
622
|
+
if (compAll)
|
623
|
+
return &compVarString_bin<unsigned short, T_CMP_ALL>;
|
624
|
+
return &compVarString_bin<unsigned short, T_CMP_PART>;
|
625
|
+
case ft_mywvarchar:
|
626
|
+
if (sizeByte == 1)
|
627
|
+
{
|
628
|
+
if (incase)
|
629
|
+
{
|
630
|
+
if (compAll)
|
631
|
+
return &compWVarString_i<unsigned char, T_CMP_ALL>;
|
632
|
+
return &compWVarString_i<unsigned char, T_CMP_PART>;
|
633
|
+
}
|
634
|
+
if (compAll)
|
635
|
+
return &compWVarString<unsigned char, T_CMP_ALL>;
|
636
|
+
return &compWVarString<unsigned char, T_CMP_PART>;
|
637
|
+
}
|
638
|
+
if (incase)
|
639
|
+
{
|
640
|
+
if (compAll)
|
641
|
+
return &compWVarString_i<unsigned short, T_CMP_ALL>;
|
642
|
+
return &compWVarString_i<unsigned short, T_CMP_PART>;
|
643
|
+
}
|
644
|
+
if (compAll)
|
645
|
+
return &compWVarString<unsigned short, T_CMP_ALL>;
|
646
|
+
return &compWVarString<unsigned short, T_CMP_PART>;
|
647
|
+
case ft_mywvarbinary:
|
648
|
+
if (sizeByte == 1)
|
649
|
+
{
|
650
|
+
if (incase)
|
651
|
+
{
|
652
|
+
if (compAll)
|
653
|
+
return &compWVarString_bin_i<unsigned char, T_CMP_ALL>;
|
654
|
+
return &compWVarString_bin_i<unsigned char, T_CMP_PART>;
|
655
|
+
}
|
656
|
+
if (compAll)
|
657
|
+
return &compWVarString_bin<unsigned char, T_CMP_ALL>;
|
658
|
+
return &compWVarString_bin<unsigned char, T_CMP_PART>;
|
659
|
+
}
|
660
|
+
if (incase)
|
661
|
+
{
|
662
|
+
if (compAll)
|
663
|
+
return &compWVarString_bin_i<unsigned short, T_CMP_ALL>;
|
664
|
+
return &compWVarString_bin_i<unsigned short, T_CMP_PART>;
|
665
|
+
}
|
666
|
+
if (compAll)
|
667
|
+
return &compWVarString_bin<unsigned short, T_CMP_ALL>;
|
668
|
+
return &compWVarString_bin<unsigned short, T_CMP_PART>;
|
669
|
+
case ft_mytext:
|
670
|
+
{
|
671
|
+
if (compAll)
|
672
|
+
{
|
673
|
+
if (incase)
|
674
|
+
{
|
675
|
+
switch(sizeByte)
|
676
|
+
{
|
677
|
+
case 1:return &compBlob_i<1, T_CMP_ALL>;
|
678
|
+
case 2:return &compBlob_i<2, T_CMP_ALL>;
|
679
|
+
case 3:return &compBlob_i<3, T_CMP_ALL>;
|
680
|
+
case 4:return &compBlob_i<4, T_CMP_ALL>;
|
681
|
+
}
|
682
|
+
}
|
683
|
+
switch(sizeByte)
|
684
|
+
{
|
685
|
+
case 1:return &compBlob<1, T_CMP_ALL>;
|
686
|
+
case 2:return &compBlob<2, T_CMP_ALL>;
|
687
|
+
case 3:return &compBlob<3, T_CMP_ALL>;
|
688
|
+
case 4:return &compBlob<4, T_CMP_ALL>;
|
689
|
+
}
|
690
|
+
}
|
691
|
+
if (incase)
|
692
|
+
{
|
693
|
+
switch(sizeByte)
|
694
|
+
{
|
695
|
+
case 1:return &compBlob_i<1, T_CMP_PART>;
|
696
|
+
case 2:return &compBlob_i<2, T_CMP_PART>;
|
697
|
+
case 3:return &compBlob_i<3, T_CMP_PART>;
|
698
|
+
case 4:return &compBlob_i<4, T_CMP_PART>;
|
699
|
+
}
|
700
|
+
}
|
701
|
+
switch(sizeByte)
|
702
|
+
{
|
703
|
+
case 1:return &compBlob<1, T_CMP_PART>;
|
704
|
+
case 2:return &compBlob<2, T_CMP_PART>;
|
705
|
+
case 3:return &compBlob<3, T_CMP_PART>;
|
706
|
+
case 4:return &compBlob<4, T_CMP_PART>;
|
707
|
+
}
|
708
|
+
}
|
709
|
+
case ft_myblob:
|
710
|
+
case ft_myjson: //TODO Json binary comp
|
711
|
+
case ft_mygeometry: //TODO geometory binary comp
|
712
|
+
{
|
713
|
+
if (compAll)
|
714
|
+
{
|
715
|
+
if (incase)
|
716
|
+
{
|
717
|
+
switch(sizeByte)
|
718
|
+
{
|
719
|
+
case 1:return &compBlob_bin_i<1, T_CMP_ALL>;
|
720
|
+
case 2:return &compBlob_bin_i<2, T_CMP_ALL>;
|
721
|
+
case 3:return &compBlob_bin_i<3, T_CMP_ALL>;
|
722
|
+
case 4:return &compBlob_bin_i<4, T_CMP_ALL>;
|
723
|
+
}
|
724
|
+
}
|
725
|
+
switch(sizeByte)
|
726
|
+
{
|
727
|
+
case 1:return &compBlob_bin<1, T_CMP_ALL>;
|
728
|
+
case 2:return &compBlob_bin<2, T_CMP_ALL>;
|
729
|
+
case 3:return &compBlob_bin<3, T_CMP_ALL>;
|
730
|
+
case 4:return &compBlob_bin<4, T_CMP_ALL>;
|
731
|
+
}
|
732
|
+
}
|
733
|
+
if (incase)
|
734
|
+
{
|
735
|
+
switch(sizeByte)
|
736
|
+
{
|
737
|
+
case 1:return &compBlob_bin_i<1, T_CMP_PART>;
|
738
|
+
case 2:return &compBlob_bin_i<2, T_CMP_PART>;
|
739
|
+
case 3:return &compBlob_bin_i<3, T_CMP_PART>;
|
740
|
+
case 4:return &compBlob_bin_i<4, T_CMP_PART>;
|
741
|
+
}
|
742
|
+
}
|
743
|
+
switch(sizeByte)
|
744
|
+
{
|
745
|
+
case 1:return &compBlob_bin<1, T_CMP_PART>;
|
746
|
+
case 2:return &compBlob_bin<2, T_CMP_PART>;
|
747
|
+
case 3:return &compBlob_bin<3, T_CMP_PART>;
|
748
|
+
case 4:return &compBlob_bin<4, T_CMP_PART>;
|
749
|
+
}
|
750
|
+
assert(0);
|
751
|
+
}
|
752
|
+
}
|
753
|
+
return NULL;
|
754
|
+
}
|
755
|
+
|
756
|
+
inline bool isMatch1(int v) // eEqual eBitAnd
|
757
|
+
{
|
758
|
+
return (v == 0);
|
759
|
+
}
|
760
|
+
|
761
|
+
inline bool isMatch2(int v) // eGreater
|
762
|
+
{
|
763
|
+
return (v > 0);
|
764
|
+
}
|
765
|
+
|
766
|
+
inline bool isMatch3(int v) // eLess
|
767
|
+
{
|
768
|
+
return (v < 0);
|
769
|
+
}
|
770
|
+
|
771
|
+
inline bool isMatch4(int v) // eNotEq eNotBitAnd
|
772
|
+
{
|
773
|
+
return (v != 0);
|
774
|
+
}
|
775
|
+
|
776
|
+
inline bool isMatch5(int v) // eGreaterEq
|
777
|
+
{
|
778
|
+
return (v >= 0);
|
779
|
+
}
|
780
|
+
|
781
|
+
inline bool isMatch6(int v) // eLessEq
|
782
|
+
{
|
783
|
+
return (v <= 0);
|
784
|
+
}
|
785
|
+
|
786
|
+
inline judgeFunc getJudgeFunc(eCompType log)
|
787
|
+
{
|
788
|
+
switch (log & 0xF)
|
789
|
+
{
|
790
|
+
case eEqual:
|
791
|
+
case eBitAnd:
|
792
|
+
return isMatch1;
|
793
|
+
case eGreater:
|
794
|
+
return isMatch2;
|
795
|
+
case eLess:
|
796
|
+
return isMatch3;
|
797
|
+
case eNotEq:
|
798
|
+
return isMatch4;
|
799
|
+
case eNotBitAnd:
|
800
|
+
case eGreaterEq:
|
801
|
+
return isMatch5;
|
802
|
+
case eLessEq:
|
803
|
+
return isMatch6;
|
804
|
+
case eIsNull:
|
805
|
+
case eIsNotNull:
|
806
|
+
return NULL;
|
807
|
+
}
|
808
|
+
assert(0);
|
809
|
+
return NULL;
|
810
|
+
}
|
811
|
+
|
812
|
+
inline bool isEndComp(uchar_td opr, bool ret)
|
813
|
+
{
|
814
|
+
return (opr == eCend) || (!ret && (opr == eCand)) || (ret && (opr == eCor));
|
815
|
+
}
|
816
|
+
|
133
817
|
#endif
|