$darkmode

| Qore DataProvider Module Reference 2.7.1

AbstractDataProviderRecordIterator.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
25// assume local scope for variables, do not use "$" signs
26// require type definitions everywhere
28// enable all warnings
29
31 namespace DataProvider {
38 const DP_OP_AND = "AND";
39
41 const DP_OP_OR = "OR";
43
49
51 const DP_SEARCH_OP_REGEX = "regex";
52
54
56 const DP_SEARCH_OP_LT = "<";
57
59
61 const DP_SEARCH_OP_LE = "<=";
62
64
66 const DP_SEARCH_OP_GT = ">";
67
69
71 const DP_SEARCH_OP_GE = ">=";
72
74
76 const DP_SEARCH_OP_NE = "!=";
77
79
81 const DP_SEARCH_OP_EQ = "=";
82
84
86 const DP_SEARCH_OP_BETWEEN = "between";
87
89
91 const DP_SEARCH_OP_IN = "in";
92
94
96 const DP_SEARCH_OP_NOT = "not";
98
100 public struct SearchOperatorInfo {
101 string op;
102 auto arg;
103};
104
106 const DefaultGenericSearchOpMap = {
107 DP_SEARCH_OP_REGEX: (
108 "code": bool sub (hash<auto> cmd, auto field_value, string field_name, hash<auto> rec) {
109 return regex(field_value.toString(), cmd.arg.pattern, cmd.arg.options);
110 },
111 ),
112 DP_SEARCH_OP_LT: (
113 "code": bool sub (hash<auto> cmd, auto field_value, string field_name, hash<auto> rec) {
114 return field_value < cmd.arg;
115 },
116 ),
117 DP_SEARCH_OP_LE: (
118 "code": bool sub (hash<auto> cmd, auto field_value, string field_name, hash<auto> rec) {
119 return field_value <= cmd.arg;
120 },
121 ),
122 DP_SEARCH_OP_GT: (
123 "code": bool sub (hash<auto> cmd, auto field_value, string field_name, hash<auto> rec) {
124 return field_value > cmd.arg;
125 },
126 ),
127 DP_SEARCH_OP_GE: (
128 "code": bool sub (hash<auto> cmd, auto field_value, string field_name, hash<auto> rec) {
129 return field_value >= cmd.arg;
130 },
131 ),
132 DP_SEARCH_OP_NE: (
133 "code": bool sub (hash<auto> cmd, auto field_value, string field_name, hash<auto> rec) {
134 return field_value != cmd.arg;
135 },
136 ),
137 DP_SEARCH_OP_EQ: (
138 "code": bool sub (hash<auto> cmd, auto field_value, string field_name, hash<auto> rec) {
139 return field_value == cmd.arg;
140 },
141 ),
142 DP_SEARCH_OP_BETWEEN: (
143 "code": bool sub (hash<auto> cmd, auto field_value, string field_name, hash<auto> rec) {
144 return field_value >= cmd.arg[0] && field_value <= cmd.arg[1];
145 },
146 ),
147 DP_SEARCH_OP_IN: (
148 "code": bool sub (hash<auto> cmd, auto field_value, string field_name, hash<auto> rec) {
149 return cmd.arg ? (cmd.arg{field_value} ?? False) : !field_value.val();
150 },
151 ),
152 DP_SEARCH_OP_NOT: (
153 "recursive": True,
154 "code": bool sub (hash<auto> cmd, auto field_value, string field_name, hash<auto> rec) {
155 return !field_value;
156 },
157 ),
158};
159
176 hash<SearchOperatorInfo> dp_make_op(string op, auto arg);
177
178
180
189 hash<SearchOperatorInfo> dp_op_regex(string str);
190
191
193
202 hash<SearchOperatorInfo> dp_op_like(string str);
203
204
206
215 hash<SearchOperatorInfo> dp_op_lt(auto arg);
216
217
219
228 hash<SearchOperatorInfo> dp_op_le(auto arg);
229
230
232
241 hash<SearchOperatorInfo> dp_op_gt(auto arg);
242
243
245
254 hash<SearchOperatorInfo> dp_op_ge(auto arg);
255
256
258
267 hash<SearchOperatorInfo> dp_op_ne(auto arg);
268
269
271
280 hash<SearchOperatorInfo> dp_op_eq(auto arg);
281
282
284
296 hash<SearchOperatorInfo> dp_op_between(auto l, auto r);
297
298
300
307 hash<SearchOperatorInfo> dp_op_in();
308
309
311
320 hash<SearchOperatorInfo> dp_op_in(list<auto> args);
321
322
324
331 hash<SearchOperatorInfo> dp_op_not(hash<auto> arg);
332
334
336
339 class AbstractDataProviderRecordIterator : public AbstractIterator {
340
341 public:
343
347 bool supportsBulkApi();
348
349
351
355 *AbstractDataProviderBulkRecordInterface getBulkApi();
356
357
359
361 *hash<string, AbstractDataField> getRecordType();
362
363
365
367 abstract hash<auto> getValue();
368
370
376 protected:
377 auto doMemberGate(string key);
378 public:
379
380
382
387 protected:
388 static bool matchGeneric(hash<auto> record, hash<DataProviderExpression> where_cond);
389 public:
390
391
393
398 protected:
399 static bool matchGeneric(hash<auto> record, *hash<auto> where_cond);
400 public:
401
402
404 protected:
405 static bool evalOperator(string field, hash<auto> cmd, hash<auto> op, hash<auto> record);
406 public:
407
408
410
413 protected:
414 static bool matchGenericValue(auto expects, auto val);
415 public:
416
417};
418};
DataProvider::AbstractDataProviderBulkRecordInterface
Defines the abstract class for data provider iterators; the destructor releases the iterator.
Definition: AbstractDataProviderBulkRecordInterface.qc.dox.h:33
DataProvider::AbstractDataProviderRecordIterator
Defines the abstract class for data provider iterators; the destructor releases the iterator.
Definition: AbstractDataProviderRecordIterator.qc.dox.h:339
DataProvider::AbstractDataProviderRecordIterator::matchGeneric
static bool matchGeneric(hash< auto > record, *hash< auto > where_cond)
Checks if the current record matches the search criteria.
DataProvider::AbstractDataProviderRecordIterator::getValue
abstract hash< auto > getValue()
returns a single record if the iterator is valid
DataProvider::AbstractDataProviderRecordIterator::matchGenericValue
static bool matchGenericValue(auto expects, auto val)
Match a single value.
DataProvider::AbstractDataProviderRecordIterator::evalOperator
static bool evalOperator(string field, hash< auto > cmd, hash< auto > op, hash< auto > record)
Evaluates a generic search operator on the field value and record and returns the result.
DataProvider::AbstractDataProviderRecordIterator::getBulkApi
*AbstractDataProviderBulkRecordInterface getBulkApi()
Returns the bulk data interface if supported.
DataProvider::AbstractDataProviderRecordIterator::supportsBulkApi
bool supportsBulkApi()
Returns True if the iterator supports bulk operation.
DataProvider::AbstractDataProviderRecordIterator::matchGeneric
static bool matchGeneric(hash< auto > record, hash< DataProviderExpression > where_cond)
Checks if the current record matches the search criteria.
DataProvider::AbstractDataProviderRecordIterator::doMemberGate
auto doMemberGate(string key)
Returns the value of the given field in the current record, if the iterator is valid.
DataProvider::AbstractDataProviderRecordIterator::getRecordType
*hash< string, AbstractDataField > getRecordType()
Returns the record description, if available.
True
const True
False
const False
DataProvider::dp_op_ge
hash< SearchOperatorInfo > dp_op_ge(auto arg)
returns an SearchOperatorInfo hash for the ">=" operator with the given argument
DataProvider::dp_op_in
hash< SearchOperatorInfo > dp_op_in()
returns an SearchOperatorInfo hash for the "in" operator with all arguments passed to the function
DataProvider::dp_op_between
hash< SearchOperatorInfo > dp_op_between(auto l, auto r)
returns an SearchOperatorInfo hash for the "between" operator with the given arguments
DataProvider::dp_op_lt
hash< SearchOperatorInfo > dp_op_lt(auto arg)
returns an SearchOperatorInfo hash for the "<" operator with the given argument
DataProvider::dp_op_regex
hash< SearchOperatorInfo > dp_op_regex(string str)
returns an SearchOperatorInfo hash for regular expression matches
DataProvider::dp_op_like
hash< SearchOperatorInfo > dp_op_like(string str)
returns an SearchOperatorInfo hash for the SQL-like "like" operator with the given argument
DataProvider::dp_op_eq
hash< SearchOperatorInfo > dp_op_eq(auto arg)
returns an SearchOperatorInfo hash for the "=" operator with the given argument
DataProvider::dp_op_gt
hash< SearchOperatorInfo > dp_op_gt(auto arg)
returns an SearchOperatorInfo hash for the ">" operator with the given argument
DataProvider::dp_op_not
hash< SearchOperatorInfo > dp_op_not(hash< auto > arg)
returns an SearchOperatorInfo hash for the "not" operator
DataProvider::dp_op_le
hash< SearchOperatorInfo > dp_op_le(auto arg)
returns an SearchOperatorInfo hash for the "<=" operator with the given argument
DataProvider::dp_op_ne
hash< SearchOperatorInfo > dp_op_ne(auto arg)
returns an SearchOperatorInfo hash for the "!=" or "<>" operator with the given argument
DataProvider::dp_make_op
hash< SearchOperatorInfo > dp_make_op(string op, auto arg)
DataProvider::DP_SEARCH_OP_EQ
const DP_SEARCH_OP_EQ
Identifies the generic data provider equals operator (=) for use in generic search criteria.
Definition: AbstractDataProviderRecordIterator.qc.dox.h:81
DataProvider::DP_SEARCH_OP_REGEX
const DP_SEARCH_OP_REGEX
Definition: AbstractDataProviderRecordIterator.qc.dox.h:51
DataProvider::DP_SEARCH_OP_GT
const DP_SEARCH_OP_GT
Identifies the generic data provider greater than operator (>) for use in generic search criteria.
Definition: AbstractDataProviderRecordIterator.qc.dox.h:66
DataProvider::DP_SEARCH_OP_IN
const DP_SEARCH_OP_IN
Identifies the generic data provider "in" operator for use in generic search criteria.
Definition: AbstractDataProviderRecordIterator.qc.dox.h:91
DataProvider::DP_SEARCH_OP_GE
const DP_SEARCH_OP_GE
Identifies the generic data provider greater than or equals operator (>=) for use in generic search c...
Definition: AbstractDataProviderRecordIterator.qc.dox.h:71
DataProvider::DP_SEARCH_OP_BETWEEN
const DP_SEARCH_OP_BETWEEN
Identifies the generic data provider "between" operator for use in generic search criteria.
Definition: AbstractDataProviderRecordIterator.qc.dox.h:86
DataProvider::DP_SEARCH_OP_NE
const DP_SEARCH_OP_NE
Identifies the generic data provider not equals operator (!= or <>) for use in generic search criteri...
Definition: AbstractDataProviderRecordIterator.qc.dox.h:76
DataProvider::DP_SEARCH_OP_NOT
const DP_SEARCH_OP_NOT
Identifies the generic data provider "not" operator for use in generic search criteria.
Definition: AbstractDataProviderRecordIterator.qc.dox.h:96
DataProvider::DP_SEARCH_OP_LT
const DP_SEARCH_OP_LT
Identifies the generic data provider less than (<) operator for use in generic search criteria.
Definition: AbstractDataProviderRecordIterator.qc.dox.h:56
DataProvider::DP_SEARCH_OP_LE
const DP_SEARCH_OP_LE
Identifies the generic data provider less than or equals (<=) operator for use in generic search crit...
Definition: AbstractDataProviderRecordIterator.qc.dox.h:61
DataProvider::DP_OP_OR
const DP_OP_OR
OR logic.
Definition: AbstractDataProviderRecordIterator.qc.dox.h:41
DataProvider::DP_OP_AND
const DP_OP_AND
Definition: AbstractDataProviderRecordIterator.qc.dox.h:38
regex
bool regex(string str, string regex, int options=0)
DataProvider
Qore AbstractDataField class definition.
Definition: AbstractDataField.qc.dox.h:27
DataProvider::DefaultGenericSearchOpMap
const DefaultGenericSearchOpMap
a hash of valid operators for use in generic search criteria
Definition: AbstractDataProviderRecordIterator.qc.dox.h:106
DataProvider::SearchOperatorInfo
Generic operator info hash as returned by all generic search operator functions.
Definition: AbstractDataProviderRecordIterator.qc.dox.h:100
DataProvider::SearchOperatorInfo::op
string op
the operator string code
Definition: AbstractDataProviderRecordIterator.qc.dox.h:101
DataProvider::SearchOperatorInfo::arg
auto arg
optional argument
Definition: AbstractDataProviderRecordIterator.qc.dox.h:102