全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 ページ
fieldComp.h
1 #ifndef BZS_DB_PROTOCOL_TDAP_FIELD_COMP_H
2 #define BZS_DB_PROTOCOL_TDAP_FIELD_COMP_H
3 /*=================================================================
4  Copyright (C) 2014 BizStation Corp All rights reserved.
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19  02111-1307, USA.
20 =================================================================*/
21 #include <bzs/db/protocol/tdap/tdapcapi.h>
22 #include <bzs/env/crosscompile.h>
23 #include <algorithm>
24 #include <string.h>
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 
161 inline int compareUint24(const char* l, const char* r)
162 {
163  unsigned int lv = int24toUint(l);
164  unsigned int rv = int24toUint(r);;
165  if (lv < rv)
166  return -1;
167  if (lv > rv)
168  return 1;
169  return 0;
170 }
171 
172 inline int compareInt24(const char* l, const char* r)
173 {
174  int lv = int24toInt(l);
175  int rv = int24toInt(r);
176 
177  if (lv < rv)
178  return -1;
179  else if (lv > rv)
180  return 1;
181  return 0;
182 }
183 
184 template <class T> inline int compare(const char* l, const char* r)
185 {
186  if (*((T*)l) < *((T*)r))
187  return -1;
188  else if (*((T*)l) > *((T*)r))
189  return 1;
190  return 0;
191 }
192 
193 template <class T> inline int bitMask(const char* l, const char* r)
194 {
195  T v = *((T*)l) & *((T*)r);
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);
202 }
203 
204 template <class T> inline int compare(T l, T r)
205 {
206  if (l < r)
207  return -1;
208  else if (l > r)
209  return 1;
210  return 0;
211 }
212 
213 template <class T>
214 inline int compareVartype(const char* l, const char* r, bool bin, bool all, bool incase)
215 {
216  int llen = (*(T*)l);
217  int rlen = (*(T*)r);
218  int tmp = std::min<int>(llen, rlen);
219  if (incase)
220  tmp = _strnicmp(l + sizeof(T), r + sizeof(T), tmp);
221  else if (bin)
222  tmp = memcmp(l + sizeof(T), r + sizeof(T), tmp);
223  else
224  tmp = strncmp(l + sizeof(T), r + sizeof(T), tmp);
225 
226  if (all)
227  return (tmp == 0) ? compare<int>(llen, rlen) : tmp; // match complete
228  return (tmp == 0 && (llen < rlen)) ? -1 : tmp; // match a part
229 }
230 
231 template <class T>
232 inline int compareWvartype(const char* l, const char* r, bool bin, bool all, bool incase)
233 {
234  int llen = (*(T*)l) / sizeof(char16_t);
235  int rlen = (*(T*)r) / sizeof(char16_t);
236  int tmp = std::min<int>(llen, rlen);
237  if (incase)
238  tmp = wcsnicmp16((char16_t*)(l + sizeof(T)), (char16_t*)(r + sizeof(T)),
239  tmp);
240  else if (bin)
241  tmp =
242  wmemcmp16((char16_t*)(l + sizeof(T)), (char16_t*)(r + sizeof(T)), tmp);
243  else
244  tmp = wcsncmp16((char16_t*)(l + sizeof(T)), (char16_t*)(r + sizeof(T)),
245  tmp);
246  if (all)
247  return (tmp == 0) ? compare<int>(llen, rlen) : tmp; // match complete
248  return (tmp == 0 && (llen < rlen)) ? -1 : tmp; // match a part
249 }
250 
251 inline int compareBlobType(const char* l, const char* r, bool bin, bool all, bool incase,
252  int sizeByte)
253 {
254  int llen = 0;
255  int rlen = 0;
256  memcpy(&llen, l, sizeByte);
257  memcpy(&rlen, r, sizeByte);
258  int tmp = std::min<int>(llen, rlen);
259  const char* lptr = *((const char**)(l + sizeByte));
260  const char* rptr = r + sizeByte;
261  if (incase)
262  tmp = _strnicmp(lptr, rptr, tmp);
263  else if (bin)
264  tmp = memcmp(lptr, rptr, tmp);
265  else
266  tmp = strncmp(lptr, rptr, tmp);
267 
268  if (all)
269  return (tmp == 0) ? compare<int>(llen, rlen) : tmp;
270  return (tmp == 0 && (llen < rlen)) ? -1 : tmp;
271 }
272 
273 inline int compareBlobType2(const char* l, const char* r, bool bin, bool all, bool incase,
274  int sizeByte)
275 {
276  int llen = 0;
277  int rlen = 0;
278  memcpy(&llen, l, sizeByte);
279  memcpy(&rlen, r, sizeByte);
280  int tmp = std::min<int>(llen, rlen);
281  const char* lptr = *((const char**)(l + sizeByte));
282  const char* rptr = *((const char**)(r + sizeByte));
283  if (incase)
284  tmp = _strnicmp(lptr, rptr, tmp);
285  else if (bin)
286  tmp = memcmp(lptr, rptr, tmp);
287  else
288  tmp = strncmp(lptr, rptr, tmp);
289 
290  if (all)
291  return (tmp == 0) ? compare<int>(llen, rlen) : tmp;
292  return (tmp == 0 && (llen < rlen)) ? -1 : tmp;
293 }
294 /* int nullComp(bool lnull, bool rnull, char log)
295 
296  lnull rnull log ret
297  -----------------------------------------------
298  true true isNull 0
299  true true isNotNull -1
300  true false 0 -1
301  false true isNull 1
302  false true isNotNull 0
303  false false 0 2
304  -----------------------------------------------
305 
306  real value example
307 
308  lval rval ret
309  -----------------------------------------------
310  NULL isNull 0
311  NULL isNotNull -1
312  NULL 2 -1
313  1 isNull 1
314  1 isNotNull 0
315  1 2 2
316  -----------------------------------------------
317 */
318 inline int nullComp(bool lnull, bool rnull, char log)
319 {
320  if (lnull)
321  return (log == eIsNull) ? 0 : -1;
322  else if (rnull)
323  return (log == eIsNull) ? 1 : 0;
324  return 2;
325 }
326 
327 template <class T>
328 inline int compBitAnd(const char* l, const char* r, int len)
329 {
330  return bitMask<T>(l, r);
331 }
332 
333 inline int compBitAnd24(const char* l, const char* r, int len)
334 {
335  int lv = int24toInt(l);
336  int rv = int24toInt(r);
337  return bitMask<int>((const char*)&lv, (const char*)&rv);
338 }
339 
340 inline int compBitAnd64(const char* l, const char* r, int len)
341 {
342  __int64 lv = 0;
343  __int64 rv = 0;
344  memcpy(&lv, l, len);
345  memcpy(&rv, r, len);
346  return bitMask<__int64>((const char*)&lv, (const char*)&rv);
347 }
348 
349 template <class T>
350 inline int compNumber(const char* l, const char* r, int len)
351 {
352  return compare<T>(l, r);
353 }
354 
355 inline int compNumber24(const char* l, const char* r, int len)
356 {
357  return compareInt24(l, r);
358 }
359 
360 inline int compNumberU24(const char* l, const char* r, int len)
361 {
362  return compareUint24(l, r);
363 }
364 
365 inline int compMem(const char* l, const char* r, int len)
366 {
367  return memcmp(l, r, len);
368 }
369 
370 inline int compString(const char* l, const char* r, int len)
371 {
372  return strncmp(l, r, len);
373 }
374 
375 inline int compiString(const char* l, const char* r, int len)
376 {
377  return _strnicmp(l, r, len);
378 }
379 
380 inline int compWString(const char* l, const char* r, int len)
381 {
382  return wcsncmp16((char16_t*)l, (char16_t*)r, len/2);
383 }
384 
385 inline int compiWString(const char* l, const char* r, int len)
386 {
387  return wcsnicmp16((char16_t*)l, (char16_t*)r, len/2);
388 }
389 
390 #define T_BIN true
391 #define T_STR false
392 
393 #define T_INCASE true
394 #define T_CASE false
395 
396 #define T_CMP_ALL true
397 #define T_CMP_PART false
398 
399 
400 template <class T, bool all>
401 inline int compVarString(const char* l, const char* r, int len)
402 {
403  return compareVartype<T>(l, r, T_STR, all, T_CASE);
404 }
405 
406 template <class T, bool all>
407 inline int compVarString_bin(const char* l, const char* r, int len)
408 {
409  return compareVartype<T>(l, r, T_BIN, all, T_CASE);
410 }
411 template <class T, bool all>
412 inline int compVarString_i(const char* l, const char* r, int len)
413 {
414  return compareVartype<T>(l, r, T_STR, all, T_INCASE);
415 }
416 
417 template <class T, bool all>
418 inline int compVarString_bin_i(const char* l, const char* r, int len)
419 {
420  return compareVartype<T>(l, r, T_BIN, all, T_INCASE);
421 }
422 
423 template <class T, bool all>
424 inline int compWVarString(const char* l, const char* r, int len)
425 {
426  return compareWvartype<T>(l, r, T_STR, all, T_CASE);
427 }
428 
429 template <class T, bool all>
430 inline int compWVarString_bin(const char* l, const char* r, int len)
431 {
432  return compareWvartype<T>(l, r, T_BIN, all, T_CASE);
433 }
434 
435 template <class T, bool all>
436 inline int compWVarString_i(const char* l, const char* r, int len)
437 {
438  return compareWvartype<T>(l, r, T_STR, all, T_INCASE);
439 }
440 
441 template <class T, bool all>
442 inline int compWVarString_bin_i(const char* l, const char* r, int len)
443 {
444  return compareWvartype<T>(l, r, T_BIN, all, T_INCASE);
445 }
446 
447 template <int sizeByte, bool all>
448 inline int compBlob(const char* l, const char* r, int len)
449 {
450  return compareBlobType(l, r, T_STR, all, T_CASE, sizeByte);
451 }
452 
453 template <int sizeByte, bool all>
454 inline int compBlob_bin(const char* l, const char* r, int len)
455 {
456  return compareBlobType(l, r, T_BIN, all, T_CASE, sizeByte);
457 }
458 
459 template <int sizeByte, bool all>
460 inline int compBlob_i(const char* l, const char* r, int len)
461 {
462  return compareBlobType(l, r, T_STR, all, T_INCASE, sizeByte);
463 }
464 
465 template <int sizeByte, bool all>
466 inline int compBlob_bin_i(const char* l, const char* r, int len)
467 {
468  return compareBlobType(l, r, T_BIN, all, T_INCASE, sizeByte);
469 }
470 
471 template <int sizeByte, bool all>
472 inline int compBlob2(const char* l, const char* r, int len)
473 {
474  return compareBlobType2(l, r, T_STR, all, T_CASE, sizeByte);
475 }
476 
477 template <int sizeByte, bool all>
478 inline int compBlob2_bin(const char* l, const char* r, int len)
479 {
480  return compareBlobType2(l, r, T_BIN, all, T_CASE, sizeByte);
481 }
482 
483 template <int sizeByte, bool all>
484 inline int compBlob2_i(const char* l, const char* r, int len)
485 {
486  return compareBlobType2(l, r, T_STR, all, T_INCASE, sizeByte);
487 }
488 
489 template <int sizeByte, bool all>
490 inline int compBlob2_bin_i(const char* l, const char* r, int len)
491 {
492  return compareBlobType2(l, r, T_BIN, all, T_INCASE, sizeByte);
493 }
494 
495 
496 typedef int (*comp1Func)(const char* l, const char* r,int len);
497 
498 typedef bool (*judgeFunc)(int);
499 
500 inline comp1Func getCompFunc(uchar_td type, ushort_td len, char logType, int sizeByte)
501 {
502  bool compAll = (logType & CMPLOGICAL_VAR_COMP_ALL) != 0;
503  bool incase = (logType & CMPLOGICAL_CASEINSENSITIVE) != 0;
504  switch (type)
505  {
506  case ft_integer:
507  case ft_autoinc:
508  case ft_currency:
509  {
510  if (logType & (char)eBitAnd)
511  {
512  switch (len)
513  {
514  case 1:
515  return &compBitAnd<char>;
516  case 2:
517  return &compBitAnd<short>;
518  case 3:
519  return &compBitAnd24;
520  case 4:
521  return &compBitAnd<int>;
522  case 8:
523  return &compBitAnd<__int64>;
524  }
525  }else
526  {
527  switch (len)
528  {
529  case 1:
530  return &compNumber<char>;
531  case 2:
532  return &compNumber<short>;
533  case 3:
534  return &compNumber24;
535  case 4:
536  return &compNumber<int>;
537  case 8:
538  return &compNumber<__int64>;
539  }
540  }
541  }
542  case ft_mychar:
543  case ft_string:
544  if (incase)
545  return &compiString;
546  return &compMem;
547  case ft_zstring:
548  case ft_note:
549  if (incase)
550  return &compiString;
551  return &compString;
552  case ft_logical:
553  case ft_uinteger:
554  case ft_autoIncUnsigned:
555  case ft_date:
556  case ft_time:
557  case ft_timestamp:
558  case ft_myyear:
559  case ft_mydate:
560  case ft_mytime_num_cmp:
561  case ft_mydatetime_num_cmp:
562  case ft_mytimestamp_num_cmp:
563  case ft_set:
564  case ft_enum:
565  {
566  if (logType & (char)eBitAnd)
567  {
568  switch (len)
569  {
570  case 1:
571  return &compBitAnd<char>;
572  case 2:
573  return &compBitAnd<short>;
574  case 3:
575  return &compBitAnd24;
576  case 4:
577  return &compBitAnd<int>;
578  case 8:
579  return &compBitAnd<__int64>;
580  }
581  }else
582  {
583  switch (len)
584  {
585  case 1:
586  return &compNumber<unsigned char>;
587  case 2:
588  return &compNumber<unsigned short>;
589  case 3:
590  return &compNumberU24;
591  case 4:
592  return &compNumber<unsigned int>;
593  case 8:
594  return &compNumber<unsigned __int64>;
595  }
596  }
597  }
598  case ft_bit:
599  if (logType & (char)eBitAnd)
600  return &compBitAnd64;
601  return &compMem;
602  case ft_mytime:
603  case ft_mydatetime:
604  case ft_mytimestamp:
605  case ft_mydecimal:
606  return &compMem;
607  case ft_float:
608  switch (len)
609  {
610  case 4:
611  return &compNumber<float>;
612  case 8:
613  return &compNumber<double>;
614  }
615  case ft_mywchar:
616  case ft_wstring:
617  case ft_wzstring:
618  if (incase)
619  return &compiWString;
620  if ((type == ft_wstring) || (type == ft_mywchar))
621  return &compMem;
622  return &compWString;
623  case ft_lstring:
624  case ft_myvarchar:
625  if (sizeByte == 1)
626  {
627  if (incase)
628  {
629  if (compAll)
630  return &compVarString_i<unsigned char, T_CMP_ALL>;
631  return &compVarString_i<unsigned char, T_CMP_PART>;
632  }else
633  {
634  if (compAll)
635  return &compVarString<unsigned char, T_CMP_ALL>;
636  return &compVarString<unsigned char, T_CMP_PART>;
637  }
638  }
639  if (incase)
640  {
641  if (compAll)
642  return &compVarString_i<unsigned short, T_CMP_ALL>;
643  return &compVarString_i<unsigned short, T_CMP_PART>;
644  }
645  if (compAll)
646  return &compVarString<unsigned short, T_CMP_ALL>;
647  return &compVarString<unsigned short, T_CMP_PART>;
648  case ft_myvarbinary:
649  if (sizeByte == 1)
650  {
651  if (incase)
652  {
653  if (compAll)
654  return &compVarString_bin_i<unsigned char, T_CMP_ALL>;
655  return &compVarString_bin_i<unsigned char, T_CMP_PART>;
656  }
657  if (compAll)
658  return &compVarString_bin<unsigned char, T_CMP_ALL>;
659  return &compVarString_bin<unsigned char, T_CMP_PART>;
660  }
661  if (incase)
662  {
663  if (compAll)
664  return &compVarString_bin_i<unsigned short, T_CMP_ALL>;
665  return &compVarString_bin_i<unsigned short, T_CMP_PART>;
666  }
667  if (compAll)
668  return &compVarString_bin<unsigned short, T_CMP_ALL>;
669  return &compVarString_bin<unsigned short, T_CMP_PART>;
670  case ft_mywvarchar:
671  if (sizeByte == 1)
672  {
673  if (incase)
674  {
675  if (compAll)
676  return &compWVarString_i<unsigned char, T_CMP_ALL>;
677  return &compWVarString_i<unsigned char, T_CMP_PART>;
678  }
679  if (compAll)
680  return &compWVarString<unsigned char, T_CMP_ALL>;
681  return &compWVarString<unsigned char, T_CMP_PART>;
682  }
683  if (incase)
684  {
685  if (compAll)
686  return &compWVarString_i<unsigned short, T_CMP_ALL>;
687  return &compWVarString_i<unsigned short, T_CMP_PART>;
688  }
689  if (compAll)
690  return &compWVarString<unsigned short, T_CMP_ALL>;
691  return &compWVarString<unsigned short, T_CMP_PART>;
692  case ft_mywvarbinary:
693  if (sizeByte == 1)
694  {
695  if (incase)
696  {
697  if (compAll)
698  return &compWVarString_bin_i<unsigned char, T_CMP_ALL>;
699  return &compWVarString_bin_i<unsigned char, T_CMP_PART>;
700  }
701  if (compAll)
702  return &compWVarString_bin<unsigned char, T_CMP_ALL>;
703  return &compWVarString_bin<unsigned char, T_CMP_PART>;
704  }
705  if (incase)
706  {
707  if (compAll)
708  return &compWVarString_bin_i<unsigned short, T_CMP_ALL>;
709  return &compWVarString_bin_i<unsigned short, T_CMP_PART>;
710  }
711  if (compAll)
712  return &compWVarString_bin<unsigned short, T_CMP_ALL>;
713  return &compWVarString_bin<unsigned short, T_CMP_PART>;
714  case ft_mytext:
715  {
716  bool rblob = (logType & CMPLOGICAL_FIELD) != 0;
717  if (rblob)
718  {
719  if (compAll)
720  {
721  if (incase)
722  {
723  switch(sizeByte)
724  {
725  case 1:return &compBlob2_i<1, T_CMP_ALL>;
726  case 2:return &compBlob2_i<2, T_CMP_ALL>;
727  case 3:return &compBlob2_i<3, T_CMP_ALL>;
728  case 4:return &compBlob2_i<4, T_CMP_ALL>;
729  }
730  }
731  switch(sizeByte)
732  {
733  case 1:return &compBlob2<1, T_CMP_ALL>;
734  case 2:return &compBlob2<2, T_CMP_ALL>;
735  case 3:return &compBlob2<3, T_CMP_ALL>;
736  case 4:return &compBlob2<4, T_CMP_ALL>;
737  }
738  }
739  if (incase)
740  {
741  switch(sizeByte)
742  {
743  case 1:return &compBlob2_i<1, T_CMP_PART>;
744  case 2:return &compBlob2_i<2, T_CMP_PART>;
745  case 3:return &compBlob2_i<3, T_CMP_PART>;
746  case 4:return &compBlob2_i<4, T_CMP_PART>;
747  }
748  }
749  switch(sizeByte)
750  {
751  case 1:return &compBlob2<1, T_CMP_PART>;
752  case 2:return &compBlob2<2, T_CMP_PART>;
753  case 3:return &compBlob2<3, T_CMP_PART>;
754  case 4:return &compBlob2<4, T_CMP_PART>;
755  }
756  }else
757  {
758  if (compAll)
759  {
760  if (incase)
761  {
762  switch(sizeByte)
763  {
764  case 1:return &compBlob_i<1, T_CMP_ALL>;
765  case 2:return &compBlob_i<2, T_CMP_ALL>;
766  case 3:return &compBlob_i<3, T_CMP_ALL>;
767  case 4:return &compBlob_i<4, T_CMP_ALL>;
768  }
769  }
770  switch(sizeByte)
771  {
772  case 1:return &compBlob<1, T_CMP_ALL>;
773  case 2:return &compBlob<2, T_CMP_ALL>;
774  case 3:return &compBlob<3, T_CMP_ALL>;
775  case 4:return &compBlob<4, T_CMP_ALL>;
776  }
777  }
778  if (incase)
779  {
780  switch(sizeByte)
781  {
782  case 1:return &compBlob_i<1, T_CMP_PART>;
783  case 2:return &compBlob_i<2, T_CMP_PART>;
784  case 3:return &compBlob_i<3, T_CMP_PART>;
785  case 4:return &compBlob_i<4, T_CMP_PART>;
786  }
787  }
788  switch(sizeByte)
789  {
790  case 1:return &compBlob<1, T_CMP_PART>;
791  case 2:return &compBlob<2, T_CMP_PART>;
792  case 3:return &compBlob<3, T_CMP_PART>;
793  case 4:return &compBlob<4, T_CMP_PART>;
794  }
795  }
796  }
797  case ft_myblob:
798  case ft_myjson: //TODO Json binary comp
799  case ft_mygeometry: //TODO geometory binary comp
800  {
801  bool rblob = (logType & CMPLOGICAL_FIELD) != 0;
802  if (rblob)
803  {
804  if (compAll)
805  {
806  if (incase)
807  {
808  switch(sizeByte)
809  {
810  case 1:return &compBlob2_bin_i<1, T_CMP_ALL>;
811  case 2:return &compBlob2_bin_i<2, T_CMP_ALL>;
812  case 3:return &compBlob2_bin_i<3, T_CMP_ALL>;
813  case 4:return &compBlob2_bin_i<4, T_CMP_ALL>;
814  }
815  }
816  switch(sizeByte)
817  {
818  case 1:return &compBlob2_bin<1, T_CMP_ALL>;
819  case 2:return &compBlob2_bin<2, T_CMP_ALL>;
820  case 3:return &compBlob2_bin<3, T_CMP_ALL>;
821  case 4:return &compBlob2_bin<4, T_CMP_ALL>;
822  }
823  }
824  if (incase)
825  {
826  switch(sizeByte)
827  {
828  case 1:return &compBlob2_bin_i<1, T_CMP_PART>;
829  case 2:return &compBlob2_bin_i<2, T_CMP_PART>;
830  case 3:return &compBlob2_bin_i<3, T_CMP_PART>;
831  case 4:return &compBlob2_bin_i<4, T_CMP_PART>;
832  }
833  }
834  switch(sizeByte)
835  {
836  case 1:return &compBlob2_bin<1, T_CMP_PART>;
837  case 2:return &compBlob2_bin<2, T_CMP_PART>;
838  case 3:return &compBlob2_bin<3, T_CMP_PART>;
839  case 4:return &compBlob2_bin<4, T_CMP_PART>;
840  }
841  }
842  else
843  {
844  if (compAll)
845  {
846  if (incase)
847  {
848  switch(sizeByte)
849  {
850  case 1:return &compBlob_bin_i<1, T_CMP_ALL>;
851  case 2:return &compBlob_bin_i<2, T_CMP_ALL>;
852  case 3:return &compBlob_bin_i<3, T_CMP_ALL>;
853  case 4:return &compBlob_bin_i<4, T_CMP_ALL>;
854  }
855  }
856  switch(sizeByte)
857  {
858  case 1:return &compBlob_bin<1, T_CMP_ALL>;
859  case 2:return &compBlob_bin<2, T_CMP_ALL>;
860  case 3:return &compBlob_bin<3, T_CMP_ALL>;
861  case 4:return &compBlob_bin<4, T_CMP_ALL>;
862  }
863  }
864  if (incase)
865  {
866  switch(sizeByte)
867  {
868  case 1:return &compBlob_bin_i<1, T_CMP_PART>;
869  case 2:return &compBlob_bin_i<2, T_CMP_PART>;
870  case 3:return &compBlob_bin_i<3, T_CMP_PART>;
871  case 4:return &compBlob_bin_i<4, T_CMP_PART>;
872  }
873  }
874  switch(sizeByte)
875  {
876  case 1:return &compBlob_bin<1, T_CMP_PART>;
877  case 2:return &compBlob_bin<2, T_CMP_PART>;
878  case 3:return &compBlob_bin<3, T_CMP_PART>;
879  case 4:return &compBlob_bin<4, T_CMP_PART>;
880  }
881  }
882  assert(0);
883  }
884  }
885  return NULL;
886 }
887 
888 inline bool isMatch1(int v) // eEqual eBitAnd
889 {
890  return (v == 0);
891 }
892 
893 inline bool isMatch2(int v) // eGreater
894 {
895  return (v > 0);
896 }
897 
898 inline bool isMatch3(int v) // eLess
899 {
900  return (v < 0);
901 }
902 
903 inline bool isMatch4(int v) // eNotEq eNotBitAnd
904 {
905  return (v != 0);
906 }
907 
908 inline bool isMatch5(int v) // eGreaterEq
909 {
910  return (v >= 0);
911 }
912 
913 inline bool isMatch6(int v) // eLessEq
914 {
915  return (v <= 0);
916 }
917 
918 inline judgeFunc getJudgeFunc(eCompType log)
919 {
920  switch (log & 0xF)
921  {
922  case eEqual:
923  case eBitAnd:
924  return isMatch1;
925  case eGreater:
926  return isMatch2;
927  case eLess:
928  return isMatch3;
929  case eNotEq:
930  case eNotBitAnd:
931  return isMatch4;
932  case eGreaterEq:
933  return isMatch5;
934  case eLessEq:
935  return isMatch6;
936  case eIsNull:
937  case eIsNotNull:
938  return NULL;
939  }
940  assert(0);
941  return NULL;
942 }
943 
944 inline bool isEndComp(uchar_td opr, bool ret)
945 {
946  return (opr == eCend) || (!ret && (opr == eCand)) || (ret && (opr == eCor));
947 }
948 
949 #endif

Transactd SDK 2018年07月31日(火) 19時40分21秒 doxygen