Collation algorithm example

Here is an example of a table-driven collation algorithm, which uses the data pointer arg to say what table to use. The DLL would have the following entries exported from it:

uca_t _en_US_ = { ... };
uca_t _fr_FR_ = { ... };

int UCAsort(void *arg, int l1, const void *s1, 
            int l2, const void *s2)
{
}

struct qdb_collation en_US = {
     "en_US", SQLITE_UTF8, &_en_US_, UCAsort, NULL };

struct qdb_collation fr_FR = {
     "fr_FR", SQLITE_UTF8, &_fr_FR_, UCAsort, NULL };

Note that both collations call the UCASort() function, but they pass in different data pointers (&_en_US_ vs. &_fr_FR_), where those are tables inside the DLL that tell it how to sort in English or French. This is passed as the first argument to the function, arg.

You would install these to QDB in the configuration object as:

Collation::en_US@/usr/lib/libqdb_uca.so,fr_FR@/usr/lib/libqdb_uca.so