SWC-DB
v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
Comparators.cc
Go to the documentation of this file.
1
/*
2
* SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3
* License details at <https://github.com/kashirin-alex/swc-db/#license>
4
*/
5
6
7
8
#include "
swcdb/core/Comparators.h
"
9
10
11
namespace
SWC
{
namespace
Condition {
12
13
14
15
Comp
from
(
const
char
** buf, uint32_t* remainp, uint8_t extended) noexcept {
16
Comp
comp =
Comp::NONE
;
17
18
if
(*remainp > 7) {
19
if
(
str_case_eq
(*buf,
"posubset"
, 8))
20
comp =
Comp::POSBS
;
21
else
if
(
str_case_eq
(*buf,
"posupset"
, 8))
22
comp =
Comp::POSPS
;
23
else
if
(
str_case_eq
(*buf,
"fosubset"
, 8))
24
comp =
Comp::FOSBS
;
25
else
if
(
str_case_eq
(*buf,
"fosupset"
, 8))
26
comp =
Comp::FOSPS
;
27
28
if
(comp !=
Comp::NONE
) {
29
*buf += 8;
30
*remainp -= 8;
31
return
comp;
32
}
33
}
34
35
if
(*remainp > 5) {
36
if
(
str_case_eq
(*buf,
"subset"
, 6))
37
comp =
Comp::SBS
;
38
else
if
(
str_case_eq
(*buf,
"supset"
, 6))
39
comp =
Comp::SPS
;
40
41
if
(comp !=
Comp::NONE
) {
42
*buf += 6;
43
*remainp -= 6;
44
return
comp;
45
}
46
}
47
48
if
(*remainp > 4) {
49
if
(
str_case_eq
(*buf,
"posbs"
, 5))
50
comp =
Comp::POSBS
;
51
else
if
(
str_case_eq
(*buf,
"posps"
, 5))
52
comp =
Comp::POSPS
;
53
else
if
(
str_case_eq
(*buf,
"fosbs"
, 5))
54
comp =
Comp::FOSBS
;
55
else
if
(
str_case_eq
(*buf,
"fosps"
, 5))
56
comp =
Comp::FOSPS
;
57
58
if
(comp !=
Comp::NONE
) {
59
*buf += 5;
60
*remainp -= 5;
61
return
comp;
62
}
63
}
64
65
if
(*remainp > 2) {
66
if
(
str_case_eq
(*buf,
"sbs"
, 3)) {
67
comp =
Comp::SBS
;
68
}
else
if
(
str_case_eq
(*buf,
"sps"
, 3)) {
69
comp =
Comp::SPS
;
70
}
else
if
(extended) {
71
if
(extended &
COMP_EXTENDED_VALUE
) {
72
if
(
str_case_eq
(*buf,
COMP_VGE
, 3) ||
73
str_case_eq
(*buf,
"vge"
, 3))
74
comp =
Comp::VGE
;
75
else
if
(
str_case_eq
(*buf,
COMP_VLE
, 3) ||
76
str_case_eq
(*buf,
"vle"
, 3))
77
comp =
Comp::VLE
;
78
else
if
(
str_case_eq
(*buf,
"vgt"
, 3))
79
comp =
Comp::VGT
;
80
else
if
(
str_case_eq
(*buf,
"vlt"
, 3))
81
comp =
Comp::VLT
;
82
}
83
if
(extended &
COMP_EXTENDED_KEY
) {
84
if
(
str_case_eq
(*buf,
"fip"
, 3))
85
comp =
Comp::FIP
;
86
}
87
}
88
if
(comp !=
Comp::NONE
) {
89
*buf += 3;
90
*remainp -= 3;
91
return
comp;
92
}
93
}
94
95
if
(*remainp > 1) {
96
if
(
str_case_eq
(*buf,
COMP_PF
, 2) ||
97
str_case_eq
(*buf,
"pf"
, 2))
98
comp =
Comp::PF
;
99
else
if
(
str_case_eq
(*buf,
COMP_GE
, 2) ||
100
str_case_eq
(*buf,
"ge"
, 2))
101
comp =
Comp::GE
;
102
else
if
(
str_case_eq
(*buf,
COMP_LE
, 2) ||
103
str_case_eq
(*buf,
"le"
, 2))
104
comp =
Comp::LE
;
105
else
if
(
str_case_eq
(*buf,
COMP_NE
, 2) ||
106
str_case_eq
(*buf,
"ne"
, 2))
107
comp =
Comp::NE
;
108
else
if
(
str_case_eq
(*buf,
COMP_RE
, 2))
109
comp =
Comp::RE
;
110
else
if
(
str_case_eq
(*buf,
COMP_EQ
, 2) ||
111
str_case_eq
(*buf,
"eq"
, 2))
112
comp =
Comp::EQ
;
113
else
if
(
str_case_eq
(*buf,
"gt"
, 2))
114
comp =
Comp::GT
;
115
else
if
(
str_case_eq
(*buf,
"lt"
, 2))
116
comp =
Comp::LT
;
117
else
if
(
str_case_eq
(*buf,
COMP_SBS
, 2))
118
comp =
Comp::SBS
;
119
else
if
(
str_case_eq
(*buf,
COMP_SPS
, 2))
120
comp =
Comp::SPS
;
121
else
if
(
str_case_eq
(*buf,
COMP_POSBS
, 2))
122
comp =
Comp::POSBS
;
123
else
if
(
str_case_eq
(*buf,
COMP_POSPS
, 2))
124
comp =
Comp::POSPS
;
125
else
if
(
str_case_eq
(*buf,
COMP_FOSBS
, 2))
126
comp =
Comp::FOSBS
;
127
else
if
(
str_case_eq
(*buf,
COMP_FOSPS
, 2)) {
128
comp =
Comp::FOSPS
;
129
}
else
if
(extended) {
130
if
(extended &
COMP_EXTENDED_VALUE
) {
131
if
(
str_case_eq
(*buf,
COMP_VGT
, 2))
132
comp =
Comp::VGT
;
133
else
if
(
str_case_eq
(*buf,
COMP_VLT
, 2))
134
comp =
Comp::VLT
;
135
}
136
if
(extended &
COMP_EXTENDED_KEY
) {
137
if
(
str_case_eq
(*buf,
COMP_FIP
, 2))
138
comp =
Comp::FIP
;
139
else
if
(
str_case_eq
(*buf,
"fi"
, 2))
140
comp =
Comp::FI
;
141
}
142
}
143
144
if
(comp !=
Comp::NONE
) {
145
*buf += 2;
146
*remainp -= 2;
147
return
comp;
148
}
149
}
150
151
if
(*remainp > 0) {
152
if
(**buf ==
'>'
)
153
comp =
Comp::GT
;
154
else
if
(**buf ==
'<'
)
155
comp =
Comp::LT
;
156
else
if
(**buf ==
'='
)
157
comp =
Comp::EQ
;
158
else
if
(extended &
COMP_EXTENDED_KEY
&& **buf ==
':'
)
159
comp =
Comp::FI
;
160
else
if
(**buf ==
'r'
|| **buf ==
'R'
)
161
comp =
Comp::RE
;
162
163
if
(comp !=
Comp::NONE
) {
164
*buf += 1;
165
*remainp -= 1;
166
return
comp;
167
}
168
}
169
170
return
comp;
171
}
172
173
174
const
char
*
to_string
(
Comp
comp) noexcept {
175
176
switch
(comp) {
177
case
Comp::EQ
:
178
return
COMP_EQ
;
179
case
Comp::PF
:
180
return
COMP_PF
;
181
case
Comp::GT
:
182
return
COMP_GT
;
183
case
Comp::GE
:
184
return
COMP_GE
;
185
case
Comp::LE
:
186
return
COMP_LE
;
187
case
Comp::LT
:
188
return
COMP_LT
;
189
case
Comp::NE
:
190
return
COMP_NE
;
191
case
Comp::RE
:
192
return
COMP_RE
;
193
case
Comp::SBS
:
194
return
COMP_SBS
;
195
case
Comp::SPS
:
196
return
COMP_SPS
;
197
case
Comp::POSBS
:
198
return
COMP_POSBS
;
199
case
Comp::POSPS
:
200
return
COMP_POSPS
;
201
case
Comp::FOSBS
:
202
return
COMP_FOSBS
;
203
case
Comp::FOSPS
:
204
return
COMP_FOSPS
;
205
case
Comp::VGT
:
206
return
COMP_VGT
;
207
case
Comp::VGE
:
208
return
COMP_VGE
;
209
case
Comp::VLE
:
210
return
COMP_VLE
;
211
case
Comp::VLT
:
212
return
COMP_VLT
;
213
case
Comp::FIP
:
214
return
COMP_FIP
;
215
case
Comp::FI
:
216
return
COMP_FI
;
217
default
:
218
return
COMP_NONE
;
219
}
220
}
221
222
223
224
225
bool
re
(
const
re2::RE2& regex,
const
re2::StringPiece& value) {
226
return
re2::RE2::PartialMatch(value, regex);
227
}
228
229
230
231
} }
// namespace SWC::Condition
SWC::Condition::LE
@ LE
Definition:
Comparators.h:33
SWC::Condition::POSPS
@ POSPS
Definition:
Comparators.h:48
SWC::Condition::FOSPS
@ FOSPS
Definition:
Comparators.h:50
SWC::Condition::GE
@ GE
Definition:
Comparators.h:31
SWC::Condition::COMP_FOSPS
const char COMP_FOSPS[]
Definition:
Comparators.h:100
SWC::Condition::COMP_VLT
const char COMP_VLT[]
Definition:
Comparators.h:94
SWC::Condition::COMP_RE
const char COMP_RE[]
Definition:
Comparators.h:90
SWC::Condition::COMP_NE
const char COMP_NE[]
Definition:
Comparators.h:89
SWC::Condition::GT
@ GT
Definition:
Comparators.h:30
SWC::Condition::COMP_EXTENDED_VALUE
const uint COMP_EXTENDED_VALUE
Definition:
Comparators.h:24
SWC::Condition::LT
@ LT
Definition:
Comparators.h:34
SWC::Condition::COMP_EXTENDED_KEY
const uint COMP_EXTENDED_KEY
Definition:
Comparators.h:25
SWC::Condition::RE
@ RE
Definition:
Comparators.h:36
SWC::Condition::VGT
@ VGT
Definition:
Comparators.h:39
SWC::Condition::VGE
@ VGE
Definition:
Comparators.h:40
SWC::Condition::COMP_GT
const char COMP_GT[]
Definition:
Comparators.h:84
SWC::Condition::COMP_NONE
const char COMP_NONE[]
Definition:
Comparators.h:82
SWC::Condition::Comp
Comp
Definition:
Comparators.h:27
SWC::Condition::FIP
@ FIP
Definition:
Comparators.h:75
SWC::Condition::COMP_POSBS
const char COMP_POSBS[]
Definition:
Comparators.h:97
SWC
The SWC-DB C++ namespace 'SWC'.
Definition:
main.cc:12
SWC::Condition::COMP_GE
const char COMP_GE[]
Definition:
Comparators.h:85
SWC::Condition::EQ
@ EQ
Definition:
Comparators.h:32
SWC::Condition::COMP_FI
const char COMP_FI[]
Definition:
Comparators.h:102
SWC::Condition::COMP_VLE
const char COMP_VLE[]
Definition:
Comparators.h:93
SWC::Condition::NE
@ NE
Definition:
Comparators.h:35
SWC::Condition::COMP_POSPS
const char COMP_POSPS[]
Definition:
Comparators.h:98
SWC::Condition::PF
@ PF
Definition:
Comparators.h:29
SWC::Condition::COMP_SBS
const char COMP_SBS[]
Definition:
Comparators.h:95
Comparators.h
SWC::Condition::COMP_PF
const char COMP_PF[]
Definition:
Comparators.h:83
SWC::Condition::COMP_EQ
const char COMP_EQ[]
Definition:
Comparators.h:86
SWC::Condition::NONE
@ NONE
Definition:
Comparators.h:28
SWC::Condition::re
bool re(const re2::RE2 ®ex, const re2::StringPiece &value)
Definition:
Comparators.cc:225
SWC::Condition::SPS
@ SPS
Definition:
Comparators.h:46
SWC::Condition::POSBS
@ POSBS
Definition:
Comparators.h:47
SWC::Condition::from
Comp from(const char **buf, uint32_t *remainp, uint8_t extended=0x00) noexcept
Definition:
Comparators.cc:15
SWC::Condition::to_string
const char *SWC_CONST_FUNC to_string(Comp comp) noexcept
Definition:
Comparators.cc:174
SWC::Condition::VLT
@ VLT
Definition:
Comparators.h:42
SWC::Condition::FI
@ FI
Definition:
Comparators.h:76
SWC::Condition::SBS
@ SBS
Definition:
Comparators.h:45
SWC::Condition::COMP_FOSBS
const char COMP_FOSBS[]
Definition:
Comparators.h:99
SWC::Condition::COMP_SPS
const char COMP_SPS[]
Definition:
Comparators.h:96
SWC::Condition::FOSBS
@ FOSBS
Definition:
Comparators.h:49
SWC::Condition::COMP_VGT
const char COMP_VGT[]
Definition:
Comparators.h:91
SWC::Condition::COMP_VGE
const char COMP_VGE[]
Definition:
Comparators.h:92
SWC::Condition::COMP_LE
const char COMP_LE[]
Definition:
Comparators.h:87
SWC::Condition::str_case_eq
bool str_case_eq(const char *s1, const char *s2, size_t count) noexcept SWC_ATTRIBS((SWC_ATTRIB_O3))
Definition:
Comparators_basic.h:257
SWC::Condition::COMP_LT
const char COMP_LT[]
Definition:
Comparators.h:88
SWC::Condition::COMP_FIP
const char COMP_FIP[]
Definition:
Comparators.h:101
SWC::Condition::VLE
@ VLE
Definition:
Comparators.h:41
lib
swcdb
core
Comparators.cc
Generated on Sat Jun 3 2023 18:00:08 for SWC-DB by
1.8.20