summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bd23ae3)
raw | patch | inline | side by side (parent: bd23ae3)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 15 Oct 2014 13:57:24 +0000 (15:57 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 15 Oct 2014 13:57:24 +0000 (15:57 +0200) |
src/core/store-private.h | patch | blob | history | |
src/core/store_lookup.c | patch | blob | history | |
src/include/core/store.h | patch | blob | history |
index 1633d42c5672e867bec3de21b10153b6c7931274..a64c22094b539574c7158bd2e11e1bd2556ad849 100644 (file)
--- a/src/core/store-private.h
+++ b/src/core/store-private.h
MATCHER_CMP_LT,
MATCHER_CMP_LE,
MATCHER_CMP_EQ,
+ MATCHER_CMP_NE,
MATCHER_CMP_GE,
MATCHER_CMP_GT,
MATCHER_REGEX,
+ MATCHER_NREGEX,
MATCHER_ISNULL,
};
: ((t) == MATCHER_LT) ? "<" \
: ((t) == MATCHER_LE) ? "<=" \
: ((t) == MATCHER_EQ) ? "=" \
+ : ((t) == MATCHER_CMP_NE) ? "!=" \
: ((t) == MATCHER_GE) ? ">=" \
: ((t) == MATCHER_GT) ? ">" \
: ((t) == MATCHER_REGEX) ? "=~" \
+ : ((t) == MATCHER_NREGEX) ? "!~" \
: ((t) == MATCHER_ISNULL) ? "IS NULL" \
: "UNKNOWN")
index a86743e7cedc4d2fff72c950f580bce0925dc00d..cb3629c89eff652d34721e33bac763415a208bf0 100644 (file)
--- a/src/core/store_lookup.c
+++ b/src/core/store_lookup.c
return (status != INT_MAX) && (! status);
} /* match_cmp_eq */
+static int
+match_cmp_ne(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
+ sdb_store_matcher_t *filter)
+{
+ int status;
+ assert(m->type == MATCHER_CMP_NE);
+ status = cmp_expr(CMP_M(m)->left, CMP_M(m)->right, obj, filter);
+ return (status != INT_MAX) && status;
+} /* match_cmp_ne */
+
static int
match_cmp_ge(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
sdb_store_matcher_t *filter)
regex_t regex;
_Bool free_regex = 0;
- assert(m->type == MATCHER_REGEX);
+ assert((m->type == MATCHER_REGEX)
+ || (m->type == MATCHER_NREGEX));
if (! CMP_M(m)->right->type) {
assert(CMP_M(m)->right->data.type == SDB_TYPE_REGEX);
if (free_regex)
regfree(®ex);
sdb_data_free_datum(&v);
+ if (m->type == MATCHER_NREGEX)
+ return !status;
return status;
} /* match_regex */
match_cmp_lt,
match_cmp_le,
match_cmp_eq,
+ match_cmp_ne,
match_cmp_ge,
match_cmp_gt,
match_regex,
+ match_regex,
match_isnull,
};
cmp_tostring,
cmp_tostring,
cmp_tostring,
+ cmp_tostring,
+ cmp_tostring,
isnull_tostring,
};
MATCHER_CMP_EQ, left, right));
} /* sdb_store_cmp_eq */
+sdb_store_matcher_t *
+sdb_store_cmp_ne(sdb_store_expr_t *left, sdb_store_expr_t *right)
+{
+ return M(sdb_object_create("ne-matcher", cmp_type,
+ MATCHER_CMP_NE, left, right));
+} /* sdb_store_cmp_ne */
+
sdb_store_matcher_t *
sdb_store_cmp_ge(sdb_store_expr_t *left, sdb_store_expr_t *right)
{
MATCHER_REGEX, left, right));
} /* sdb_store_regex_matcher */
+sdb_store_matcher_t *
+sdb_store_nregex_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right)
+{
+ sdb_store_matcher_t *m = sdb_store_regex_matcher(left, right);
+ if (! m)
+ return NULL;
+ m->type = MATCHER_NREGEX;
+ return m;
+} /* sdb_store_nregex_matcher */
+
sdb_store_matcher_t *
sdb_store_isnull_matcher(const char *attr_name)
{
index 1729f0c8bcbcedcac1dbc21f773d5d0195bd47fd..5e57185ee4d8a9639cb072e1aac261c90e2fbb07 100644 (file)
--- a/src/include/core/store.h
+++ b/src/include/core/store.h
sdb_store_matcher_t *
sdb_store_cmp_eq(sdb_store_expr_t *left, sdb_store_expr_t *right);
sdb_store_matcher_t *
+sdb_store_cmp_ne(sdb_store_expr_t *left, sdb_store_expr_t *right);
+sdb_store_matcher_t *
sdb_store_cmp_ge(sdb_store_expr_t *left, sdb_store_expr_t *right);
sdb_store_matcher_t *
sdb_store_cmp_gt(sdb_store_expr_t *left, sdb_store_expr_t *right);
sdb_store_matcher_t *
sdb_store_regex_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right);
+/*
+ * sdb_store_nregex_matcher:
+ * Creates a regex matcher just like sdb_store_regex_matcher except that it
+ * matches in case the regular expression does not match.
+ */
+sdb_store_matcher_t *
+sdb_store_nregex_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right);
+
/*
* sdb_store_parse_object_type_plural:
* Parse the type name (plural) of a stored object.