[evolution-data-server/openismus-work-3-8: 10/116] EBookQuery: Added regex query API.



commit 4871bcd8997eab774c825c711c0dbb260ee58d6e
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Tue Apr 23 17:34:54 2013 +0900

    EBookQuery: Added regex query API.
    
    Added E_BOOK_QUERY_REGEX_NORMAL and E_BOOK_QUERY_REGEX_RAW

 addressbook/libebook-contacts/e-book-query.c |   26 ++++++++++++++++++++++++++
 addressbook/libebook-contacts/e-book-query.h |   10 +++++++++-
 2 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/libebook-contacts/e-book-query.c b/addressbook/libebook-contacts/e-book-query.c
index 2a8ecb1..39e59a8 100644
--- a/addressbook/libebook-contacts/e-book-query.c
+++ b/addressbook/libebook-contacts/e-book-query.c
@@ -620,6 +620,24 @@ func_eqphone_short (struct _ESExp *f,
 }
 
 static ESExpResult *
+func_regex_normal (struct _ESExp *f,
+                  gint argc,
+                  struct _ESExpResult **argv,
+                  gpointer data)
+{
+       return func_field_test (E_BOOK_QUERY_REGEX_NORMAL, f, argc, argv, data);
+}
+
+static ESExpResult *
+func_regex_raw (struct _ESExp *f,
+               gint argc,
+               struct _ESExpResult **argv,
+               gpointer data)
+{
+       return func_field_test (E_BOOK_QUERY_REGEX_RAW, f, argc, argv, data);
+}
+
+static ESExpResult *
 func_exists (struct _ESExp *f,
              gint argc,
              struct _ESExpResult **argv,
@@ -682,6 +700,8 @@ static const struct {
        { "eqphone", func_eqphone, 0 },
        { "eqphone_national", func_eqphone_national, 0 },
        { "eqphone_short", func_eqphone_short, 0 },
+       { "regex_normal", func_regex_normal, 0 },
+       { "regex_raw", func_regex_raw, 0 },
        { "exists", func_exists, 0 },
        { "exists_vcard", func_exists_vcard, 0 }
 };
@@ -758,6 +778,10 @@ field_test_name (EBookQueryTest field_test)
                return "eqphone_national";
        case E_BOOK_QUERY_EQUALS_SHORT_PHONE_NUMBER:
                return "eqphone_short";
+       case E_BOOK_QUERY_REGEX_NORMAL:
+               return "regex_normal";
+       case E_BOOK_QUERY_REGEX_RAW:
+               return "regex_raw";
        }
 
        return NULL;
@@ -776,6 +800,8 @@ is_phone_test (EBookQueryTest field_test)
        case E_BOOK_QUERY_CONTAINS:
        case E_BOOK_QUERY_BEGINS_WITH:
        case E_BOOK_QUERY_ENDS_WITH:
+       case E_BOOK_QUERY_REGEX_NORMAL:
+       case E_BOOK_QUERY_REGEX_RAW:
                break;
        }
 
diff --git a/addressbook/libebook-contacts/e-book-query.h b/addressbook/libebook-contacts/e-book-query.h
index 264fde2..67771e8 100644
--- a/addressbook/libebook-contacts/e-book-query.h
+++ b/addressbook/libebook-contacts/e-book-query.h
@@ -29,6 +29,11 @@ typedef struct _EBookQuery EBookQuery;
  * @E_BOOK_QUERY_EQUALS_SHORT_PHONE_NUMBER: check if a field matches with a value tested
  * using e_phone_number_compare_strings(), the match must be at least of strength %E_PHONE_NUMBER_MATCH_SHORT
  * for this query to return any matches.
+ * @E_BOOK_QUERY_REGEX_NORMAL: A regular expression query against contact data normalized with 
e_util_utf8_normalize(),
+ * the normalized data is lower case with any accents removed.
+ * @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.
  *
  * The kind of test a query created by e_book_query_field_test() shall perform.
  *
@@ -42,7 +47,10 @@ typedef enum {
 
   E_BOOK_QUERY_EQUALS_PHONE_NUMBER,
   E_BOOK_QUERY_EQUALS_NATIONAL_PHONE_NUMBER,
-  E_BOOK_QUERY_EQUALS_SHORT_PHONE_NUMBER
+  E_BOOK_QUERY_EQUALS_SHORT_PHONE_NUMBER,
+
+  E_BOOK_QUERY_REGEX_NORMAL,
+  E_BOOK_QUERY_REGEX_RAW
 
   /*
     Consider these "coming soon".


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]