72 DAVQL_NOT, DAVQL_LAND, DAVQL_LOR, DAVQL_LXOR, // logical |
72 DAVQL_NOT, DAVQL_LAND, DAVQL_LOR, DAVQL_LXOR, // logical |
73 DAVQL_EQ, DAVQL_NEQ, DAVQL_LT, DAVQL_GT, DAVQL_LE, DAVQL_GE, |
73 DAVQL_EQ, DAVQL_NEQ, DAVQL_LT, DAVQL_GT, DAVQL_LE, DAVQL_GE, |
74 DAVQL_LIKE, DAVQL_UNLIKE // comparisons |
74 DAVQL_LIKE, DAVQL_UNLIKE // comparisons |
75 } davqloperator_t; |
75 } davqloperator_t; |
76 |
76 |
77 typedef struct { |
77 typedef struct DavQLToken DavQLToken; |
|
78 struct DavQLToken { |
78 davqltokenclass_t tokenclass; |
79 davqltokenclass_t tokenclass; |
79 sstr_t value; |
80 cxstring value; |
80 } DavQLToken; |
81 DavQLToken *prev; |
|
82 DavQLToken *next; |
|
83 }; |
81 |
84 |
82 /** |
85 /** |
83 * An expression within a DAVQL query. |
86 * An expression within a DAVQL query. |
84 */ |
87 */ |
85 typedef struct _davqlexpr DavQLExpression; |
88 typedef struct _davqlexpr DavQLExpression; |
137 * <ul> |
140 * <ul> |
138 * <li>SELECT: the identifier or an alias name</li> |
141 * <li>SELECT: the identifier or an alias name</li> |
139 * <li>SET: the identifier</li> |
142 * <li>SET: the identifier</li> |
140 * </ul> |
143 * </ul> |
141 */ |
144 */ |
142 sstr_t name; |
145 cxstring name; |
143 /** |
146 /** |
144 * The field expression. |
147 * The field expression. |
145 * <ul> |
148 * <ul> |
146 * <li>SELECT: the queried property (identifier) or an expression</li> |
149 * <li>SELECT: the queried property (identifier) or an expression</li> |
147 * <li>SET: the expression for the value to be set</li> |
150 * <li>SET: the expression for the value to be set</li> |
256 */ |
259 */ |
257 char* errormessage; |
260 char* errormessage; |
258 /** |
261 /** |
259 * The list of DavQLFields. |
262 * The list of DavQLFields. |
260 */ |
263 */ |
261 UcxList* fields; |
264 CxList* fields; |
262 /** |
265 /** |
263 * A string that denotes the queried path. |
266 * A string that denotes the queried path. |
264 */ |
267 */ |
265 sstr_t path; |
268 cxstring path; |
266 /** |
269 /** |
267 * Logical expression for selection. |
270 * Logical expression for selection. |
268 * <code>NULL</code>, if there is no where clause. |
271 * <code>NULL</code>, if there is no where clause. |
269 */ |
272 */ |
270 DavQLExpression* where; |
273 DavQLExpression* where; |
271 /** |
274 /** |
272 * The list of DavQLOrderCriterions. |
275 * The list of DavQLOrderCriterions. |
273 * This is <code>NULL</code> for SET queries and may be <code>NULL</code> |
276 * This is <code>NULL</code> for SET queries and may be <code>NULL</code> |
274 * if the result doesn't need to be sorted. |
277 * if the result doesn't need to be sorted. |
275 */ |
278 */ |
276 UcxList* orderby; |
279 CxList* orderby; |
277 /** |
280 /** |
278 * The recursion depth for the statement. |
281 * The recursion depth for the statement. |
279 * Defaults to 1. |
282 * Defaults to 1. |
280 * Magic numbers are DAV_DEPTH_INFINITY for infinity and |
283 * Magic numbers are DAV_DEPTH_INFINITY for infinity and |
281 * DAV_DEPTH_PLACEHOLDER for a placeholder. |
284 * DAV_DEPTH_PLACEHOLDER for a placeholder. |
282 */ |
285 */ |
283 int depth; |
286 int depth; |
284 /** |
287 /** |
285 * A list of all required arguments |
288 * A list of all required arguments |
286 */ |
289 */ |
287 UcxList* args; |
290 CxList* args; |
288 } DavQLStatement; |
291 } DavQLStatement; |
289 |
292 |
290 /** Infinity recursion depth for a DavQLStatement. */ |
293 /** Infinity recursion depth for a DavQLStatement. */ |
291 #define DAV_DEPTH_INFINITY -1 |
294 #define DAV_DEPTH_INFINITY -1 |
292 |
295 |
348 /** |
351 /** |
349 * Parses a statement. |
352 * Parses a statement. |
350 * @param stmt the sstr_t containing the statement |
353 * @param stmt the sstr_t containing the statement |
351 * @return a DavQLStatement object |
354 * @return a DavQLStatement object |
352 */ |
355 */ |
353 DavQLStatement* dav_parse_statement(sstr_t stmt); |
356 DavQLStatement* dav_parse_statement(cxstring stmt); |
354 |
357 |
355 /** |
358 /** |
356 * Implicitly converts a cstr to a sstr_t and calls dav_parse_statement. |
359 * Implicitly converts a cstr to a sstr_t and calls dav_parse_statement. |
357 */ |
360 */ |
358 #define dav_parse_cstr_statement(stmt) dav_parse_statement(S(stmt)) |
361 #define dav_parse_cstr_statement(stmt) dav_parse_statement(cx_str(stmt)) |
359 |
362 |
360 /** |
363 /** |
361 * Frees a DavQLStatement. |
364 * Frees a DavQLStatement. |
362 * @param stmt the statement object to free |
365 * @param stmt the statement object to free |
363 */ |
366 */ |