X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcore%2Fstore-private.h;h=060ec7bccf02c7b19acfccc7a6d29b5058986c01;hb=cc35394b0c4af9ccfbe7b0a18713758a9f29d247;hp=4c38f1570bca1d449a4478fa33119e410cf33136;hpb=6d0d1e3ef653bb23cb76e3330dc58c49257c8573;p=sysdb.git diff --git a/src/core/store-private.h b/src/core/store-private.h index 4c38f15..060ec7b 100644 --- a/src/core/store-private.h +++ b/src/core/store-private.h @@ -106,7 +106,9 @@ typedef struct { /* * expressions */ + enum { + TYPED_EXPR = -3, /* obj type stored in data.data.integer */ ATTR_VALUE = -2, /* attr name stored in data.data.string */ FIELD_VALUE = -1, /* field type stored in data.data.integer */ /* 0: const value (stored in data) */ @@ -124,6 +126,14 @@ struct sdb_store_expr { sdb_data_t data; }; +#define CONST_EXPR(v) { SDB_OBJECT_INIT, 0, (v).type, NULL, NULL, (v) } +#define EXPR_TO_STRING(e) \ + (((e)->type == TYPED_EXPR) ? "" \ + : ((e)->type == ATTR_VALUE) ? "attribute" \ + : ((e)->type == FIELD_VALUE) ? SDB_FIELD_TO_NAME((e)->data.data.integer) \ + : ((e)->type == 0) ? "" \ + : ((e)->type > 0) ? SDB_DATA_OP_TO_STRING((e)->type) \ + : "") /* * matchers @@ -136,44 +146,49 @@ enum { MATCHER_AND, MATCHER_NOT, MATCHER_ANY, + MATCHER_ALL, + MATCHER_IN, + MATCHER_NIN, + + /* unary operators */ + MATCHER_ISNULL, + MATCHER_ISNNULL, + + /* ary operators */ MATCHER_LT, MATCHER_LE, MATCHER_EQ, MATCHER_NE, MATCHER_GE, MATCHER_GT, - MATCHER_IN, MATCHER_REGEX, MATCHER_NREGEX, - MATCHER_ISNULL, - MATCHER_ISNNULL, + + /* a generic query */ + MATCHER_QUERY, }; #define MATCHER_SYM(t) \ (((t) == MATCHER_OR) ? "OR" \ : ((t) == MATCHER_AND) ? "AND" \ : ((t) == MATCHER_NOT) ? "NOT" \ - : ((t) == MATCHER_NAME) ? "NAME" \ : ((t) == MATCHER_ANY) ? "ANY" \ + : ((t) == MATCHER_ALL) ? "ALL" \ + : ((t) == MATCHER_IN) ? "IN" \ + : ((t) == MATCHER_NIN) ? "NOT IN" \ + : ((t) == MATCHER_ISNULL) ? "IS NULL" \ + : ((t) == MATCHER_ISNNULL) ? "IS NOT NULL" \ : ((t) == MATCHER_LT) ? "<" \ : ((t) == MATCHER_LE) ? "<=" \ : ((t) == MATCHER_EQ) ? "=" \ : ((t) == MATCHER_NE) ? "!=" \ : ((t) == MATCHER_GE) ? ">=" \ : ((t) == MATCHER_GT) ? ">" \ - : ((t) == MATCHER_IN) ? "IN" \ : ((t) == MATCHER_REGEX) ? "=~" \ : ((t) == MATCHER_NREGEX) ? "!~" \ - : ((t) == MATCHER_ISNULL) ? "IS NULL" \ - : ((t) == MATCHER_ISNNULL) ? "IS NOT NULL" \ + : ((t) == MATCHER_QUERY) ? "QUERY" \ : "UNKNOWN") -/* match the name of something */ -typedef struct { - char *name; - regex_t *name_re; -} string_matcher_t; - /* matcher base type */ struct sdb_store_matcher { sdb_object_t super; @@ -204,7 +219,7 @@ typedef struct { /* iter matcher */ typedef struct { sdb_store_matcher_t super; - int type; + sdb_store_expr_t *iter; sdb_store_matcher_t *m; } iter_matcher_t; #define ITER_M(m) ((iter_matcher_t *)(m)) @@ -219,21 +234,20 @@ typedef struct { } cmp_matcher_t; #define CMP_M(m) ((cmp_matcher_t *)(m)) -/* match any type of object by it's name */ -typedef struct { - sdb_store_matcher_t super; - - int obj_type; - string_matcher_t name; -} name_matcher_t; -#define NAME_M(m) ((name_matcher_t *)(m)) - typedef struct { sdb_store_matcher_t super; sdb_store_expr_t *expr; } isnull_matcher_t; #define ISNULL_M(m) ((isnull_matcher_t *)(m)) +typedef struct { + sdb_store_matcher_t super; + sdb_ast_node_t *ast; + sdb_store_matcher_t *matcher; + sdb_store_matcher_t *filter; +} query_matcher_t; +#define QUERY_M(m) ((query_matcher_t *)(m)) + #ifdef __cplusplus } /* extern "C" */ #endif