[gom] filter: Support the GLOB operator from SQLite
- From: Mathieu Bridon <mbridon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gom] filter: Support the GLOB operator from SQLite
- Date: Tue, 25 Nov 2014 09:20:09 +0000 (UTC)
commit 40c70a00398b9175bf05a8447f4dca055a955575
Author: Mathieu Bridon <bochecha daitauha fr>
Date: Mon Nov 24 21:46:17 2014 +0100
filter: Support the GLOB operator from SQLite
http://www.sqlite.org/lang_expr.html#like
https://bugzilla.gnome.org/show_bug.cgi?id=740657
gom/gom-filter.c | 16 ++++++++++++++--
gom/gom-filter.h | 6 +++++-
2 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/gom/gom-filter.c b/gom/gom-filter.c
index 6b077ca..381b25c 100644
--- a/gom/gom-filter.c
+++ b/gom/gom-filter.c
@@ -58,7 +58,8 @@ static const gchar *gOperators[] = {
">=",
"<",
"<=",
- "LIKE"
+ "LIKE",
+ "GLOB"
};
/**
@@ -126,6 +127,14 @@ gom_filter_new_like (GType resource_type,
}
GomFilter *
+gom_filter_new_glob (GType resource_type,
+ const gchar *property_name,
+ const GValue *value)
+{
+ return gom_filter_new_for_param(resource_type, property_name, GOM_FILTER_GLOB, value);
+}
+
+GomFilter *
gom_filter_new_eq (GType resource_type,
const gchar *property_name,
const GValue *value)
@@ -292,6 +301,7 @@ gom_filter_get_sql (GomFilter *filter,
case GOM_FILTER_LT:
case GOM_FILTER_LTE:
case GOM_FILTER_LIKE:
+ case GOM_FILTER_GLOB:
table = get_table(priv->pspec, priv->type, table_map);
ret = g_strdup_printf("'%s'.'%s' %s ?",
table,
@@ -370,7 +380,8 @@ gom_filter_get_values (GomFilter *filter)
case GOM_FILTER_GTE:
case GOM_FILTER_LT:
case GOM_FILTER_LTE:
- case GOM_FILTER_LIKE: {
+ case GOM_FILTER_LIKE:
+ case GOM_FILTER_GLOB: {
GValue v = { 0 };
g_value_init(&v, G_VALUE_TYPE(&priv->value));
g_value_copy(&priv->value, &v);
@@ -543,6 +554,7 @@ gom_filter_mode_get_type (void)
{ GOM_FILTER_LT, "GOM_FILTER_LT", "LT" },
{ GOM_FILTER_LTE, "GOM_FILTER_LTE", "LTE" },
{ GOM_FILTER_LIKE, "GOM_FILTER_LIKE", "LIKE" },
+ { GOM_FILTER_GLOB, "GOM_FILTER_GLOB", "GLOB" },
{ 0 }
};
diff --git a/gom/gom-filter.h b/gom/gom-filter.h
index 62a9de9..3494c6d 100644
--- a/gom/gom-filter.h
+++ b/gom/gom-filter.h
@@ -43,7 +43,8 @@ enum _GomFilterMode
GOM_FILTER_GTE,
GOM_FILTER_LT,
GOM_FILTER_LTE,
- GOM_FILTER_LIKE
+ GOM_FILTER_LIKE,
+ GOM_FILTER_GLOB
};
typedef struct _GomFilter GomFilter;
@@ -96,6 +97,9 @@ GomFilter *gom_filter_new_lte (GType resource_type,
GomFilter *gom_filter_new_like (GType resource_type,
const gchar *property_name,
const GValue *value);
+GomFilter *gom_filter_new_glob (GType resource_type,
+ const gchar *property_name,
+ const GValue *value);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]