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



commit e37c07ed99fc20ac0b77dd12adb66d9604d4abe5
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 |    8 ++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/addressbook/libebook-contacts/e-book-query.c b/addressbook/libebook-contacts/e-book-query.c
index f8841e1..7fe8c7a 100644
--- a/addressbook/libebook-contacts/e-book-query.c
+++ b/addressbook/libebook-contacts/e-book-query.c
@@ -606,6 +606,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,
@@ -668,6 +686,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 }
 };
@@ -744,6 +764,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";
        }
 
        g_assert_not_reached ();
@@ -762,6 +786,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 49e8b53..91f318d 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.
  *
@@ -44,6 +49,9 @@ typedef enum {
   E_BOOK_QUERY_EQUALS_NATIONAL_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]