Mon, 23 Mar 2015 14:29:30 +0100
structure draft for DavQL statements
/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 2015 Olaf Wintermann. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef DAVQLPARSER_H #define DAVQLPARSER_H #ifdef __cplusplus extern "C" { #endif #include "ucx/string.h" #include "ucx/list.h" /** * Enumeration of possible statement types. */ typedef enum {GET, PUT} davqltype_t; /** * Enumeration of possible expression types. */ typedef enum {LITERAL, UNARY, BINARY, LOGICAL} davqlexprtype_t; /** * Enumeration of possible expression operators. */ typedef enum { ADD, SUB, MUL, DIV, AND, OR, XOR, NEG, NOT, LAND, LOR } davqloperator_t; /** * An expression within a DAVQL query. */ typedef struct _davqlexpr DavQLExpression; /** * The structure for type DavQLExpression. */ struct _davqlexpr { /** * The original expression text. * Contains the literal value, if type is LITERAL. */ sstr_t srctext; /** * The expression type. */ davqlexprtype_t type; /** * Operator. * */ davqloperator_t op; /** * Left or single operand. * <code>NULL</code> for literals. */ DavQLExpression *expr1; /** * Right operand. * <code>NULL</code> for literals or unary expressions. */ DavQLExpression *expr2; }; /** * Query statement object. * Contains the binary information about the parsed query. */ typedef struct { /** * The original query text. */ sstr_t srctext; /** * The statement type. */ davqltype_t type; /** * The list of field names (sstr_t). * <ul> * <li>GET: the list of DAV properties for projection</li> * <li>PUT: the list of DAV properties that shall receive new values</li> * </ul> * This may be <code>NULL</code> for GET queries, to request all properties. */ UcxList* fields; /** * The list of DavQLExpressions for the new DAV property values. * This is <code>NULL</code> for GET queries. */ UcxList* putvalues; /** * Logical expression for selection. */ DavQLExpression* where; /** * The recursion depth for the statement. * Defaults to SIZE_MAX (unbound recursion). */ size_t depth; } DavQLStatement; #ifdef __cplusplus } #endif #endif /* DAVQLPARSER_H */