Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_query_criteria.h
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * AFW - String Functions
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 #ifndef __AFW_AFW_QUERY_CRITERIA_H__
10 #define __AFW_AFW_QUERY_CRITERIA_H__
11 
12 #include "afw_minimal.h"
13 
32 
52 typedef enum {
53  afw_query_criteria_style_operator = 0,
54  afw_query_criteria_style_operator_long = 1,
55  afw_query_criteria_style_semicolon_comma = 2,
56  afw_query_criteria_style_function = 3,
57  afw_query_criteria_style_max = 3
59 
60 
61 /* Note: Opaque typedef for afw_query_criteria_t is in afw_interface.h. */
62 
66 
67 
68 
70 typedef enum {
71  /* This can be in entry->alt_op if not applicable. */
72  afw_query_criteria_filter_op_id_na,
73 
74  /*
75  * These can be in entry->op and entry->alt_op.
76  *
77  * If only supporting these, implementation must use entry->alt_not and
78  * entry->alt_op.
79  */
80  afw_query_criteria_filter_op_id_eq,
81  afw_query_criteria_filter_op_id_lt,
82  afw_query_criteria_filter_op_id_le,
83  afw_query_criteria_filter_op_id_match,
84  afw_query_criteria_filter_op_id_contains,
85  afw_query_criteria_filter_op_id_in,
86 
87  /*
88  * These can be in entry->op. These will not be in entry->alt_op.
89  */
90  afw_query_criteria_filter_op_id_ne, /* not eq */
91  afw_query_criteria_filter_op_id_ge, /* not lt */
92  afw_query_criteria_filter_op_id_gt, /* not lte */
93  afw_query_criteria_filter_op_id_differ, /* not match */
94  afw_query_criteria_filter_op_id_excludes, /* not contains */
95  afw_query_criteria_filter_op_id_out, /* not in */
96 
97  /*
98  * These can be in entry->op, but will not be in an on_true, on_false, or
99  * entry->alt_op.
100  */
101  afw_query_criteria_filter_op_id_and,
102  afw_query_criteria_filter_op_id_or
103 
105 
106 
109 
110  /* Next sort entry. */
112 
113  /* Property name of value to use for sort. */
114  const afw_utf8_t *property_name;
115 
116  /* Sort descending if true. */
117  afw_boolean_t descending;
118 
119  /*
120  * @brief Property type or NULL (Internal use)
121  */
123 };
124 
125 
127 #define AFW_QUERY_CRITERIA_TRUE ((void *) 1)
128 
130 #define AFW_QUERY_CRITERIA_FALSE ((void *) 0)
131 
132 
139 
140  /* @brief Next entry in the order coded in query string/object traversal. */
142 
143  /* @brief Operation string. */
144  const afw_utf8_t *op_name;
145 
146  /* @brief Enum of operation to perform. */
148 
149  /* @brief Indicates alt_op is the "not" of op. */
150  afw_boolean_t alt_not;
151 
152  /*
153  * @brief Enum of operation to perform in conjunction with alt_not.
154  *
155  * Enum of alt operator that is used in conjunction with alt_not as an
156  * alternative to op. Using the alt_not/alt_op combo requires half of
157  * operators to be implemented, but requires not to be supported.
158  */
160 
161  /* Property name parameter for operation. */
162  const afw_utf8_t *property_name;
163 
164  /*
165  * Parameter for other operators converted to adaptive value based on
166  * associated _AdaptiveObjectType_.
167  */
168  const afw_value_t *value;
169 
170  /* For op match, this is an internal regexp expression. */
171  const void *op_specific;
172 
173  /* First child entry for and/or operator. */
174  const afw_query_criteria_filter_entry_t *first_conjunctive_child;
175 
176  /* Next sibling entry for and/or traversal. */
177  const afw_query_criteria_filter_entry_t *next_conjunctive_sibling;
178 
179  /*
180  * Next entry to process if this entry evaluates to true. Can also be
181  * AFW_QUERY_CRITERIA_TRUE or AFW_QUERY_CRITERIA_FALSE.
182  */
183  const afw_query_criteria_filter_entry_t *on_true;
184 
185  /*
186  * Next entry to process if this entry evaluates to false. Can also be
187  * AFW_QUERY_CRITERIA_TRUE or AFW_QUERY_CRITERIA_FALSE.
188  */
189  const afw_query_criteria_filter_entry_t *on_false;
190 
191  /*
192  * @brief Property type or NULL (Internal use)
193  */
195 };
196 
197 
218 
219  /*
220  * This is the origin unparsed query string which may or may not
221  * be NULL. This should only be used for context during debugging
222  * and should not be further interpreted. A query string can
223  * be mapped mutiple times, but the origin query string will
224  * remain the same.
225  */
226  const afw_utf8_t *origin_query_string;
227 
228  /*
229  * @brief _AdaptiveQueryCriteria_ object representing query criteria.
230  */
231  const afw_object_t *query_object;
232 
233  /*
234  * @brief Property names to return in objects.
235  *
236  * This is a NULL terminated list of property name pointers or NULL
237  * if there are none.
238  */
239  const afw_utf8_t * const *select;
240 
241  /*
242  * @brief Parsed filter.
243  *
244  * Use on_true/on_false to traverse to determine if filter is true or
245  * false. No recursion is required. There are no and/or entries since
246  * the compilation process sets on_true/on_false to true (1), false (0)
247  * or the address of the next entry to test. Note that on_true and
248  * on_false can both contain false (0) as well as true (1).
249  *
250  * The value or on_true in an entry is applicable if the comparison is
251  * true and on_false if the comparison is false. An applicable value
252  * of true (1) or false (0) is the final result of the filter test.
253  */
254  const afw_query_criteria_filter_entry_t *filter;
255 
256  /*
257  * @brief Parse tree that needs to be traversed recursively.
258  *
259  * Starting with this entry, use first_conjunctive_child and
260  * next_conjunctive_sibling to traverse tree of ands, ors, and
261  * comparisons.
262  *
263  * Also, from this entry, ->next can be used to traverse the entries
264  * in the order they appear in the query.
265  */
267 
268  /*
269  * @brief Parsed sort
270  */
271  const afw_query_criteria_sort_entry_t *first_sort;
272 
273  /*
274  * @brief Object type or NULL (Internal use)
275  */
276  const afw_object_type_t *object_type;
277 };
278 
279 
280 
302  const afw_object_t *query_object,
303  const afw_object_type_t *object_type,
304  const afw_pool_t *p, afw_xctx_t *xctx);
305 
306 
328  const afw_utf8_t *url_encoded_rql_string,
329  const afw_object_type_t *object_type,
330  const afw_pool_t *p, afw_xctx_t *xctx);
331 
332 
343  const afw_object_t *obj,
344  const afw_query_criteria_t *criteria,
345  const afw_pool_t *p,
346  afw_xctx_t *xctx);
347 
348 
356 AFW_DECLARE(const afw_object_t *)
358  const afw_query_criteria_t *criteria,
359  const afw_pool_t *p,
360  afw_xctx_t *xctx);
361 
362 
371 AFW_DECLARE(const afw_utf8_t *)
373  const afw_query_criteria_t *criteria,
375  const afw_pool_t *p,
376  afw_xctx_t *xctx);
377 
378 
379 AFW_END_DECLARES
380 
383 #endif /* __AFW_AFW_QUERY_CRITERIA_H__ */
384 
#define AFW_BEGIN_DECLARES
#define AFW_DECLARE(type)
Declare a public afw function.
Adaptive Framework Minimal Header.
_Bool afw_boolean_t
Definition: afw_common.h:373
afw_boolean_t afw_query_criteria_test_object(const afw_object_t *obj, const afw_query_criteria_t *criteria, const afw_pool_t *p, afw_xctx_t *xctx)
Test object against query criteria.
const afw_utf8_t * afw_query_criteria_to_query_string(const afw_query_criteria_t *criteria, afw_query_criteria_style_t style, const afw_pool_t *p, afw_xctx_t *xctx)
Convert query criteria to query string.
afw_query_criteria_filter_op_id_t
const afw_query_criteria_t * afw_query_criteria_parse_AdaptiveQueryCriteria_object(const afw_object_t *query_object, const afw_object_type_t *object_type, const afw_pool_t *p, afw_xctx_t *xctx)
Parse URI encoded query string.
afw_query_criteria_style_t
Query string style.
const afw_object_t * afw_query_criteria_to_AdaptiveQueryCriteria_object(const afw_query_criteria_t *criteria, const afw_pool_t *p, afw_xctx_t *xctx)
Convert query criteria to a AdaptiveQueryCriteria object.
const afw_query_criteria_t * afw_query_criteria_parse_url_encoded_rql_string(const afw_utf8_t *url_encoded_rql_string, const afw_object_type_t *object_type, const afw_pool_t *p, afw_xctx_t *xctx)
Parse URI encoded RQL query string.
Interface afw_object public struct.
Struct for afw_object_type_property_type_t.
Struct for afw_object_type_t.
Interface afw_pool public struct.
Parsed filter entry from query string.
Parsed query criteria.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Interface afw_value public struct.
Interface afw_xctx public struct.