summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 026ce2b)
raw | patch | inline | side by side (parent: 026ce2b)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 2 Sep 2015 22:13:25 +0000 (00:13 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 2 Sep 2015 22:13:25 +0000 (00:13 +0200) |
src/core/store_expr.c | patch | blob | history | |
src/include/core/store.h | patch | blob | history | |
t/unit/core/store_expr_test.c | patch | blob | history |
diff --git a/src/core/store_expr.c b/src/core/store_expr.c
index 5e15f5350b9ca26d16564317e46957e8285fbcd3..642255e4ab94c77028e1f1779d77fd56bfe3584a 100644 (file)
--- a/src/core/store_expr.c
+++ b/src/core/store_expr.c
return status;
} /* sdb_store_expr_eval */
-bool
-sdb_store_expr_iterable(sdb_store_expr_t *expr, int context)
-{
- if (expr->type == TYPED_EXPR) {
- if ((context != SDB_HOST) && (context != SDB_SERVICE)
- && (context != SDB_METRIC))
- return 0;
- if (context == expr->data.data.integer)
- return 0;
- if ((expr->data.data.integer != SDB_SERVICE)
- && (expr->data.data.integer != SDB_METRIC)
- && (expr->data.data.integer != SDB_ATTRIBUTE))
- return 0;
- if ((context == SDB_SERVICE)
- && (expr->data.data.integer == SDB_METRIC))
- return 0;
- else if ((context == SDB_METRIC)
- && (expr->data.data.integer == SDB_SERVICE))
- return 0;
- return 1;
- }
- else if (expr->type == FIELD_VALUE) {
- if ((context != SDB_HOST) && (context != SDB_SERVICE)
- && (context != SDB_METRIC) && (context != SDB_ATTRIBUTE))
- return 0;
- if (expr->data.data.integer == SDB_FIELD_BACKEND)
- return 1;
- else if (expr->data.data.integer == SDB_FIELD_VALUE)
- /* we don't current support this just like when using
- * the attribute[<name>] syntax */
- return 0;
- }
- else if (! expr->type) {
- return !!(expr->data.type & SDB_TYPE_ARRAY);
- }
- return 0;
-} /* sdb_store_expr_iterable */
-
sdb_store_expr_iter_t *
sdb_store_expr_iter(sdb_store_expr_t *expr, sdb_store_obj_t *obj,
sdb_store_matcher_t *filter)
index 28b257e056b10f6912b793c95ee592afba6ed59d..090b76bf0269bb0b59263478912e0b8cd454efa8 100644 (file)
--- a/src/include/core/store.h
+++ b/src/include/core/store.h
#define SDB_STORE_EXPR(obj) ((sdb_store_expr_t *)(obj))
/*
- * An expression iterator iterates over the values of an iterable expression
- * (see sdb_store_expr_iterable).
+ * An expression iterator iterates over the values of an iterable expression.
*/
struct sdb_store_expr_iter;
typedef struct sdb_store_expr_iter sdb_store_expr_iter_t;
sdb_store_expr_eval(sdb_store_expr_t *expr, sdb_store_obj_t *obj,
sdb_data_t *res, sdb_store_matcher_t *filter);
-/*
- * sdb_store_expr_iterable:
- * Check whether an expression, evaluated in the specified context (HOST,
- * SERVICE, METRIC) is iterable, that is, if it may evaluate to multiple
- * values.
- */
-bool
-sdb_store_expr_iterable(sdb_store_expr_t *expr, int context);
-
/*
* sdb_store_expr_iter:
* Iterate over the elements of an iterable expression. sdb_store_expr_iter
* returns NULL if the expression is not iterable (for the specified object).
- * See also sdb_store_expr_iterable.
*
* sdb_store_expr_iter_get_next returns NULL if there is no next element.
*/
index 303a921f0506ad952377ae58a7f7d13a12998d57..d11452ae72dc072e0c5fac7330fd4b29b18e4969 100644 (file)
sdb_store_matcher_t *filter = NULL;
int context = SDB_HOST;
- bool iterable;
sdb_store_expr_iter_t *iter;
size_t i;
ck_assert(filter != NULL);
}
- iterable = sdb_store_expr_iterable(&expr_iter_data[_i].expr, context);
- fail_unless(iterable == expr_iter_data[_i].iterable,
- "%s expression not iterable in %s context",
- EXPR_TO_STRING(&expr_iter_data[_i].expr),
- SDB_STORE_TYPE_TO_NAME(context));
-
iter = sdb_store_expr_iter(&expr_iter_data[_i].expr, obj, filter);
- fail_unless((iter != NULL) == iterable,
+ fail_unless((iter != NULL) == expr_iter_data[_i].iterable,
"sdb_store_expr_iter(%s expression, %s, %s) = %s; expected: %s",
EXPR_TO_STRING(&expr_iter_data[_i].expr),
obj ? SDB_STORE_TYPE_TO_NAME(obj->type) : "<array>",
expr_iter_data[_i].filter, iter ? "<iter>" : "NULL",
- iterable ? "<iter>" : "NULL");
+ expr_iter_data[_i].iterable ? "<iter>" : "NULL");
/* the iterator will keep a reference */
sdb_object_deref(SDB_OBJ(obj)); obj = NULL;