summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4319a6c)
raw | patch | inline | side by side (parent: 4319a6c)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 17 Oct 2014 06:36:42 +0000 (08:36 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 17 Oct 2014 06:36:42 +0000 (08:36 +0200) |
This function parses the string representation of an operator and returns a
constructor for the respective matcher.
constructor for the respective matcher.
src/core/store_lookup.c | patch | blob | history | |
src/include/core/store.h | patch | blob | history |
index cb3629c89eff652d34721e33bac763415a208bf0..325d67f157af587294d44e5480624d702c5bc075 100644 (file)
--- a/src/core/store_lookup.c
+++ b/src/core/store_lookup.c
MATCHER_ISNULL, attr_name));
} /* sdb_store_isnull_matcher */
+sdb_store_matcher_op_cb
+sdb_store_parse_matcher_op(const char *op)
+{
+ if (! strcasecmp(op, "<"))
+ return sdb_store_cmp_lt;
+ else if (! strcasecmp(op, "<="))
+ return sdb_store_cmp_le;
+ else if (! strcasecmp(op, "="))
+ return sdb_store_cmp_eq;
+ else if (! strcasecmp(op, "!="))
+ return sdb_store_cmp_ne;
+ else if (! strcasecmp(op, ">="))
+ return sdb_store_cmp_ge;
+ else if (! strcasecmp(op, ">"))
+ return sdb_store_cmp_gt;
+ else if (! strcasecmp(op, "=~"))
+ return sdb_store_regex_matcher;
+ else if (! strcasecmp(op, "!~"))
+ return sdb_store_nregex_matcher;
+ return NULL;
+} /* sdb_store_parse_matcher_op */
+
int
sdb_store_parse_object_type_plural(const char *name)
{
index 5e57185ee4d8a9639cb072e1aac261c90e2fbb07..147d74555c4d68a979e01d3f96249c65b6da3212 100644 (file)
--- a/src/include/core/store.h
+++ b/src/include/core/store.h
sdb_store_matcher_t *
sdb_store_nregex_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right);
+/*
+ * sdb_store_matcher_op_cb:
+ * Callback constructing a matcher operator.
+ */
+typedef sdb_store_matcher_t *(*sdb_store_matcher_op_cb)
+ (sdb_store_expr_t *, sdb_store_expr_t *);
+
+/*
+ * sdb_store_parse_matcher_op:
+ * Parse a matcher operator and return a constructor for the respective
+ * matcher.
+ *
+ * Returns:
+ * - matcher operator constructor on success
+ * - NULL else
+ */
+sdb_store_matcher_op_cb
+sdb_store_parse_matcher_op(const char *op);
+
/*
* sdb_store_parse_object_type_plural:
* Parse the type name (plural) of a stored object.