[evolution-data-server/openismus-work-master] EBookQuery: Added transliteration queries.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work-master] EBookQuery: Added transliteration queries.
- Date: Thu, 24 Oct 2013 21:30:32 +0000 (UTC)
commit 67523d676f20500c85a9272f3167b4b65052fe42
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Thu Oct 24 22:55:25 2013 +0200
EBookQuery: Added transliteration queries.
Transliterated queries come in the regular IS, CONTAINS, BEGINS_WITH and
ENDS_WITH variations. They will transliterate the query input and the
fields which they are testing all into Latin script, so that queries
are script insensitive as much as possible.
addressbook/libebook-contacts/e-book-query.c | 52 ++++++++++++++++++++++++++
addressbook/libebook-contacts/e-book-query.h | 11 +++++-
2 files changed, 62 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/libebook-contacts/e-book-query.c b/addressbook/libebook-contacts/e-book-query.c
index 688eeb0..3fc9e33 100644
--- a/addressbook/libebook-contacts/e-book-query.c
+++ b/addressbook/libebook-contacts/e-book-query.c
@@ -662,6 +662,42 @@ func_regex_raw (struct _ESExp *f,
}
static ESExpResult *
+func_translit_contains (struct _ESExp *f,
+ gint argc,
+ struct _ESExpResult **argv,
+ gpointer data)
+{
+ return func_field_test (E_BOOK_QUERY_TRANSLIT_CONTAINS, f, argc, argv, data);
+}
+
+static ESExpResult *
+func_translit_is (struct _ESExp *f,
+ gint argc,
+ struct _ESExpResult **argv,
+ gpointer data)
+{
+ return func_field_test (E_BOOK_QUERY_TRANSLIT_IS, f, argc, argv, data);
+}
+
+static ESExpResult *
+func_translit_beginswith (struct _ESExp *f,
+ gint argc,
+ struct _ESExpResult **argv,
+ gpointer data)
+{
+ return func_field_test (E_BOOK_QUERY_TRANSLIT_BEGINS_WITH, f, argc, argv, data);
+}
+
+static ESExpResult *
+func_translit_endswith (struct _ESExp *f,
+ gint argc,
+ struct _ESExpResult **argv,
+ gpointer data)
+{
+ return func_field_test (E_BOOK_QUERY_TRANSLIT_ENDS_WITH, f, argc, argv, data);
+}
+
+static ESExpResult *
func_exists (struct _ESExp *f,
gint argc,
struct _ESExpResult **argv,
@@ -726,6 +762,10 @@ static const struct {
{ "eqphone_short", func_eqphone_short, 0 },
{ "regex_normal", func_regex_normal, 0 },
{ "regex_raw", func_regex_raw, 0 },
+ { "translit_is", func_translit_is, 0 },
+ { "translit_contains", func_translit_contains, 0 },
+ { "translit_beginswith", func_translit_beginswith, 0 },
+ { "translit_endswith", func_translit_endswith, 0 },
{ "exists", func_exists, 0 },
{ "exists_vcard", func_exists_vcard, 0 }
};
@@ -806,6 +846,14 @@ field_test_name (EBookQueryTest field_test)
return "regex_normal";
case E_BOOK_QUERY_REGEX_RAW:
return "regex_raw";
+ case E_BOOK_QUERY_TRANSLIT_IS:
+ return "translit_is";
+ case E_BOOK_QUERY_TRANSLIT_CONTAINS:
+ return "translit_contains";
+ case E_BOOK_QUERY_TRANSLIT_BEGINS_WITH:
+ return "translit_beginswith";
+ case E_BOOK_QUERY_TRANSLIT_ENDS_WITH:
+ return "translit_endswith";
}
return NULL;
@@ -826,6 +874,10 @@ is_phone_test (EBookQueryTest field_test)
case E_BOOK_QUERY_ENDS_WITH:
case E_BOOK_QUERY_REGEX_NORMAL:
case E_BOOK_QUERY_REGEX_RAW:
+ case E_BOOK_QUERY_TRANSLIT_IS:
+ case E_BOOK_QUERY_TRANSLIT_CONTAINS:
+ case E_BOOK_QUERY_TRANSLIT_BEGINS_WITH:
+ case E_BOOK_QUERY_TRANSLIT_ENDS_WITH:
break;
}
diff --git a/addressbook/libebook-contacts/e-book-query.h b/addressbook/libebook-contacts/e-book-query.h
index 2c03a61..c23d4ef 100644
--- a/addressbook/libebook-contacts/e-book-query.h
+++ b/addressbook/libebook-contacts/e-book-query.h
@@ -60,6 +60,10 @@ typedef struct _EBookQuery EBookQuery;
* @E_BOOK_QUERY_REGEX_RAW: A regular expression query against raw contact data, this is usually slower than
* a %E_BOOK_QUERY_REGEX_NORMAL as it implies that #EVCards must be parsed in order to get the raw data
* for comparison.
+ * @E_BOOK_QUERY_TRANSLIT_IS: Like %E_BOOK_QUERY_IS, but transliterates text to Latin script before the
comparison
+ * @E_BOOK_QUERY_TRANSLIT_CONTAINS: Like %E_BOOK_QUERY_CONTAINS, but transliterates text to Latin script
before the comparison
+ * @E_BOOK_QUERY_TRANSLIT_BEGINS_WITH: Like %E_BOOK_QUERY_BEGINS_WITH, but transliterates text to Latin
script before the comparison
+ * @E_BOOK_QUERY_TRANSLIT_ENDS_WITH: Like %E_BOOK_QUERY_ENDS_WITH, but transliterates text to Latin script
before the comparison
*
* The kind of test a query created by e_book_query_field_test() shall perform.
*
@@ -76,7 +80,12 @@ typedef enum {
E_BOOK_QUERY_EQUALS_SHORT_PHONE_NUMBER,
E_BOOK_QUERY_REGEX_NORMAL,
- E_BOOK_QUERY_REGEX_RAW
+ E_BOOK_QUERY_REGEX_RAW,
+
+ E_BOOK_QUERY_TRANSLIT_IS,
+ E_BOOK_QUERY_TRANSLIT_CONTAINS,
+ E_BOOK_QUERY_TRANSLIT_BEGINS_WITH,
+ E_BOOK_QUERY_TRANSLIT_ENDS_WITH
/*
Consider these "coming soon".
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]