DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
cstring.hpp
Go to the documentation of this file.
1// DUNE DAQ modification notice:
2// This file has been modified from the original ATLAS oks source for the DUNE DAQ project.
3// Fork baseline commit: oks-08-03-04 (2022-04-14).
4// Renamed since fork: yes (from oks/cstring.h to include/oks/cstring.hpp).
5
6#ifndef OKS_CSTRING_CMP_H
7#define OKS_CSTRING_CMP_H
8
9#include <stdint.h>
10
11namespace dunedaq {
12namespace oks {
13
14inline bool
15cmp_str1(const char* s1, const char s2[2])
16{
17 return (*(const int16_t*)s1 == *(const int16_t*)s2);
18}
19
20inline bool
21cmp_str2(const char* s1, const char s2[3])
22{
23 return cmp_str1(s1, s2) && (s1[2] == 0);
24}
25
26inline bool
27cmp_str2n(const char* s1, const char s2[2])
28{
29 return cmp_str1(s1, s2);
30}
31
32inline bool
33cmp_str3(const char* s1, const char s2[4])
34{
35 return (*(const int32_t*)s1 == *(const int32_t*)s2);
36}
37
38inline bool
39cmp_str3n(const char* s1, const char s2[3])
40{
41 return (s1[0] == s2[0]) && cmp_str1(s1 + 1, s2 + 1);
42}
43
44inline bool
45cmp_str4(const char* s1, const char s2[5])
46{
47 return (s1[0] == s2[0]) && cmp_str3(s1 + 1, s2 + 1);
48}
49
50inline bool
51cmp_str4n(const char* s1, const char s2[4])
52{
53 return cmp_str3(s1, s2);
54}
55
56inline bool
57cmp_str5(const char* s1, const char s2[6])
58{
59 return cmp_str1(s1, s2) && cmp_str3(s1 + 2, s2 + 2);
60}
61
62inline bool
63cmp_str5n(const char* s1, const char s2[5])
64{
65 return cmp_str3(s1, s2) && (s1[4] == s2[4]);
66}
67
68inline bool
69cmp_str6(const char* s1, const char s2[7])
70{
71 return cmp_str3(s1, s2) && cmp_str2(s1 + 4, s2 + 4);
72}
73
74inline bool
75cmp_str6n(const char* s1, const char s2[6])
76{
77 return cmp_str3(s1, s2) && cmp_str1(s1 + 4, s2 + 4);
78}
79
80inline bool
81cmp_str7(const char* s1, const char s2[8])
82{
83 return (*(const int64_t*)s1 == *(const int64_t*)s2);
84}
85
86inline bool
87cmp_str7n(const char* s1, const char s2[8])
88{
89 return (cmp_str3(s1, s2) && cmp_str3n(s1 + 4, s2 + 4));
90}
91
92inline bool
93cmp_str8(const char* s1, const char s2[9])
94{
95 return cmp_str7(s1, s2) && (s1[8] == 0);
96}
97
98inline bool
99cmp_str8n(const char* s1, const char s2[9])
100{
101 return (*(const int64_t*)s1 == *(const int64_t*)s2);
102}
103
104inline bool
105cmp_str9(const char* s1, const char s2[10])
106{
107 return cmp_str1(s1, s2) && cmp_str7(s1 + 2, s2 + 2);
108}
109
110inline bool
111cmp_str10(const char* s1, const char s2[11])
112{
113 return cmp_str7(s1, s2) && cmp_str2(s1 + 8, s2 + 8);
114}
115
116inline bool
117cmp_str11(const char* s1, const char s2[12])
118{
119 return cmp_str7(s1, s2) && cmp_str3(s1 + 8, s2 + 8);
120}
121
122inline bool
123cmp_str12(const char* s1, const char s2[13])
124{
125 return cmp_str7(s1, s2) && cmp_str4(s1 + 8, s2 + 8);
126}
127
128inline bool
129cmp_str13(const char* s1, const char s2[14])
130{
131 return cmp_str7(s1, s2) && cmp_str5(s1 + 8, s2 + 8);
132}
133
134inline bool
135cmp_str14(const char* s1, const char s2[14])
136{
137 return cmp_str7(s1, s2) && cmp_str6(s1 + 8, s2 + 8);
138}
139
140inline bool
141cmp_str15(const char* s1, const char s2[16])
142{
143 return cmp_str7(s1, s2) && cmp_str7(s1 + 8, s2 + 8);
144}
145
146inline bool
147cmp_str16(const char* s1, const char s2[17])
148{
149 return cmp_str7(s1, s2) && cmp_str7(s1 + 8, s2 + 8) && (s1[16] == 0);
150}
151
152} // namespace oks
153} // namespace dunedaq
154
155#endif
bool cmp_str8(const char *s1, const char s2[9])
Definition cstring.hpp:93
bool cmp_str8n(const char *s1, const char s2[9])
Definition cstring.hpp:99
bool cmp_str2n(const char *s1, const char s2[2])
Definition cstring.hpp:27
bool cmp_str1(const char *s1, const char s2[2])
Definition cstring.hpp:15
bool cmp_str7n(const char *s1, const char s2[8])
Definition cstring.hpp:87
bool cmp_str4(const char *s1, const char s2[5])
Definition cstring.hpp:45
bool cmp_str6(const char *s1, const char s2[7])
Definition cstring.hpp:69
bool cmp_str10(const char *s1, const char s2[11])
Definition cstring.hpp:111
bool cmp_str9(const char *s1, const char s2[10])
Definition cstring.hpp:105
bool cmp_str5n(const char *s1, const char s2[5])
Definition cstring.hpp:63
bool cmp_str3n(const char *s1, const char s2[3])
Definition cstring.hpp:39
bool cmp_str13(const char *s1, const char s2[14])
Definition cstring.hpp:129
bool cmp_str16(const char *s1, const char s2[17])
Definition cstring.hpp:147
bool cmp_str2(const char *s1, const char s2[3])
Definition cstring.hpp:21
bool cmp_str15(const char *s1, const char s2[16])
Definition cstring.hpp:141
bool cmp_str5(const char *s1, const char s2[6])
Definition cstring.hpp:57
bool cmp_str11(const char *s1, const char s2[12])
Definition cstring.hpp:117
bool cmp_str3(const char *s1, const char s2[4])
Definition cstring.hpp:33
bool cmp_str12(const char *s1, const char s2[13])
Definition cstring.hpp:123
bool cmp_str6n(const char *s1, const char s2[6])
Definition cstring.hpp:75
bool cmp_str14(const char *s1, const char s2[14])
Definition cstring.hpp:135
bool cmp_str7(const char *s1, const char s2[8])
Definition cstring.hpp:81
bool cmp_str4n(const char *s1, const char s2[4])
Definition cstring.hpp:51
The DUNE-DAQ namespace.