diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-13 13:04:22 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-13 13:04:22 -0700 |
commit | 455ed29fb92a9adf411252df5e74541269d10806 (patch) | |
tree | 415f16ac36f25f3d7d8d78398e52e1fb969c77d4 /android/sqlite3_android.cpp | |
parent | b7743da3573c9fa0a726181d8f4cd7190908f27d (diff) |
auto import from //branches/cupcake_rel/...@138607
Diffstat (limited to 'android/sqlite3_android.cpp')
-rw-r--r-- | android/sqlite3_android.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/android/sqlite3_android.cpp b/android/sqlite3_android.cpp index 1723c1e..55dcd5a 100644 --- a/android/sqlite3_android.cpp +++ b/android/sqlite3_android.cpp @@ -27,6 +27,7 @@ #include "sqlite3_android.h" #include "PhoneNumberUtils.h" +#include "PhoneticStringUtils.h" #define ENABLE_ANDROID_LOG 0 @@ -69,6 +70,24 @@ static int collate8(void *p, int n1, const void *v1, int n2, const void *v2) } } +static void get_phonetically_sortable_string( + sqlite3_context * context, int argc, sqlite3_value ** argv) +{ + if (argc != 1) { + sqlite3_result_null(context); + return; + } + char const * src = (char const *)sqlite3_value_text(argv[0]); + char * ret; + size_t len; + + if (!android::GetPhoneticallySortableString(src, &ret, &len)) { + sqlite3_result_null(context); + } else { + sqlite3_result_text(context, ret, len, free); + } +} + static void phone_numbers_equal(sqlite3_context * context, int argc, sqlite3_value ** argv) { if (argc != 2) { @@ -391,6 +410,15 @@ extern "C" int register_android_functions(sqlite3 * handle, int utf16Storage) } #endif + // Register the GET_PHONETICALLY_SORTABLE_STRING function + err = sqlite3_create_function(handle, + "GET_PHONETICALLY_SORTABLE_STRING", + 1, SQLITE_UTF8, NULL, + get_phonetically_sortable_string, + NULL, NULL); + if (err != SQLITE_OK) { + return err; + } + return SQLITE_OK; } - |