Line data Source code
1 : #ifndef OKS_CSTRING_CMP_H
2 : #define OKS_CSTRING_CMP_H
3 :
4 : #include <stdint.h>
5 :
6 : namespace dunedaq {
7 : namespace oks {
8 :
9 424662 : inline bool cmp_str1(const char * s1, const char s2[2]) {
10 424662 : return (*(const int16_t *)s1 == *(const int16_t *)s2);
11 : }
12 :
13 41370 : inline bool cmp_str2(const char * s1, const char s2[3]) {
14 41370 : return cmp_str1(s1,s2) && (s1[2] == 0);
15 : }
16 :
17 26599 : inline bool cmp_str2n(const char * s1, const char s2[2]) {
18 26599 : return cmp_str1(s1,s2);
19 : }
20 :
21 736169 : inline bool cmp_str3(const char * s1, const char s2[4]) {
22 736169 : return (*(const int32_t *)s1 == *(const int32_t *)s2);
23 : }
24 :
25 118378 : inline bool cmp_str3n(const char * s1, const char s2[3]) {
26 118378 : return (s1[0] == s2[0]) && cmp_str1(s1+1,s2+1);
27 : }
28 :
29 206395 : inline bool cmp_str4(const char * s1, const char s2[5]) {
30 206395 : return (s1[0] == s2[0]) && cmp_str3(s1+1,s2+1);
31 : }
32 :
33 481647 : inline bool cmp_str4n(const char * s1, const char s2[4]) {
34 481647 : return cmp_str3(s1,s2);
35 : }
36 :
37 33432 : inline bool cmp_str5(const char * s1, const char s2[6]) {
38 33432 : return cmp_str1(s1,s2) && cmp_str3(s1+2,s2+2);
39 : }
40 :
41 783 : inline bool cmp_str5n(const char * s1, const char s2[5]) {
42 783 : return cmp_str3(s1,s2) && (s1[4] == s2[4]);
43 : }
44 :
45 68026 : inline bool cmp_str6(const char * s1, const char s2[7]) {
46 68026 : return cmp_str3(s1,s2) && cmp_str2(s1+4,s2+4);
47 : }
48 :
49 8028 : inline bool cmp_str6n(const char * s1, const char s2[6]) {
50 8028 : return cmp_str3(s1,s2) && cmp_str1(s1+4,s2+4);
51 : }
52 :
53 245173 : inline bool cmp_str7(const char * s1, const char s2[8]) {
54 245173 : return (*(const int64_t *)s1 == *(const int64_t *)s2);
55 : }
56 :
57 0 : inline bool cmp_str7n(const char * s1, const char s2[8]) {
58 0 : return (cmp_str3(s1,s2) && cmp_str3n(s1+4,s2+4));
59 : }
60 :
61 9177 : inline bool cmp_str8(const char * s1, const char s2[9]) {
62 9177 : return cmp_str7(s1,s2) && (s1[8] == 0);
63 : }
64 :
65 0 : inline bool cmp_str8n(const char * s1, const char s2[9]) {
66 0 : return (*(const int64_t *)s1 == *(const int64_t *)s2);
67 : }
68 :
69 22188 : inline bool cmp_str9(const char * s1, const char s2[10]) {
70 22188 : return cmp_str1(s1,s2) && cmp_str7(s1+2,s2+2);
71 : }
72 :
73 69946 : inline bool cmp_str10(const char * s1, const char s2[11]) {
74 69946 : return cmp_str7(s1,s2) && cmp_str2(s1+8,s2+8);
75 : }
76 :
77 72489 : inline bool cmp_str11(const char * s1, const char s2[12]) {
78 72489 : return cmp_str7(s1,s2) && cmp_str3(s1+8,s2+8);
79 : }
80 :
81 37807 : inline bool cmp_str12(const char * s1, const char s2[13]) {
82 37807 : return cmp_str7(s1,s2) && cmp_str4(s1+8,s2+8);
83 : }
84 :
85 1763 : inline bool cmp_str13(const char * s1, const char s2[14]) {
86 1763 : return cmp_str7(s1,s2) && cmp_str5(s1+8,s2+8);
87 : }
88 :
89 12099 : inline bool cmp_str14(const char * s1, const char s2[14]) {
90 12099 : return cmp_str7(s1,s2) && cmp_str6(s1+8,s2+8);
91 : }
92 :
93 777 : inline bool cmp_str15(const char * s1, const char s2[16]) {
94 777 : return cmp_str7(s1,s2) && cmp_str7(s1+8,s2+8);
95 : }
96 :
97 1295 : inline bool cmp_str16(const char * s1, const char s2[17]) {
98 1295 : return cmp_str7(s1,s2) && cmp_str7(s1+8,s2+8) && (s1[16] == 0);
99 : }
100 :
101 : } // namespace oks
102 : } // namespace dunedaq
103 :
104 : #endif
|