storage/src/SQLCollations.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/storage/src/SQLCollations.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,249 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_storage_SQLCollations_h
    1.11 +#define mozilla_storage_SQLCollations_h
    1.12 +
    1.13 +#include "mozStorageService.h"
    1.14 +#include "nscore.h"
    1.15 +#include "nsString.h"
    1.16 +
    1.17 +#include "sqlite3.h"
    1.18 +
    1.19 +namespace mozilla {
    1.20 +namespace storage {
    1.21 +
    1.22 +/**
    1.23 + * Registers the collating sequences declared here with the specified
    1.24 + * database and Service.
    1.25 + *
    1.26 + * @param  aDB
    1.27 + *         The database we'll be registering the collations with.
    1.28 + * @param  aService
    1.29 + *         The Service that owns the nsICollation used by our collations.
    1.30 + * @return the SQLite status code indicating success or failure.
    1.31 + */
    1.32 +NS_HIDDEN_(int) registerCollations(sqlite3 *aDB, Service *aService);
    1.33 +
    1.34 +////////////////////////////////////////////////////////////////////////////////
    1.35 +//// Predefined Functions
    1.36 +
    1.37 +/**
    1.38 + * Custom UTF-8 collating sequence that respects the application's locale.
    1.39 + * Comparison is case- and accent-insensitive.  This is called by SQLite.
    1.40 + *
    1.41 + * @param  aService
    1.42 + *         The Service that owns the nsICollation used by this collation.
    1.43 + * @param  aLen1
    1.44 + *         The number of bytes in aStr1.
    1.45 + * @param  aStr1
    1.46 + *         The string to be compared against aStr2.  It will be passed in by
    1.47 + *         SQLite as a non-null-terminated char* buffer.
    1.48 + * @param  aLen2
    1.49 + *         The number of bytes in aStr2.
    1.50 + * @param  aStr2
    1.51 + *         The string to be compared against aStr1.  It will be passed in by
    1.52 + *         SQLite as a non-null-terminated char* buffer.
    1.53 + * @return aStr1 - aStr2.  That is, if aStr1 < aStr2, returns a negative number.
    1.54 + *         If aStr1 > aStr2, returns a positive number.  If aStr1 == aStr2,
    1.55 + *         returns 0.
    1.56 + */
    1.57 +NS_HIDDEN_(int) localeCollation8(void *aService,
    1.58 +                                 int aLen1,
    1.59 +                                 const void *aStr1,
    1.60 +                                 int aLen2,
    1.61 +                                 const void *aStr2);
    1.62 +
    1.63 +/**
    1.64 + * Custom UTF-8 collating sequence that respects the application's locale.
    1.65 + * Comparison is case-sensitive and accent-insensitive.  This is called by
    1.66 + * SQLite.
    1.67 + *
    1.68 + * @param  aService
    1.69 + *         The Service that owns the nsICollation used by this collation.
    1.70 + * @param  aLen1
    1.71 + *         The number of bytes in aStr1.
    1.72 + * @param  aStr1
    1.73 + *         The string to be compared against aStr2.  It will be passed in by
    1.74 + *         SQLite as a non-null-terminated char* buffer.
    1.75 + * @param  aLen2
    1.76 + *         The number of bytes in aStr2.
    1.77 + * @param  aStr2
    1.78 + *         The string to be compared against aStr1.  It will be passed in by
    1.79 + *         SQLite as a non-null-terminated char* buffer.
    1.80 + * @return aStr1 - aStr2.  That is, if aStr1 < aStr2, returns a negative number.
    1.81 + *         If aStr1 > aStr2, returns a positive number.  If aStr1 == aStr2,
    1.82 + *         returns 0.
    1.83 + */
    1.84 +NS_HIDDEN_(int) localeCollationCaseSensitive8(void *aService,
    1.85 +                                              int aLen1,
    1.86 +                                              const void *aStr1,
    1.87 +                                              int aLen2,
    1.88 +                                              const void *aStr2);
    1.89 +
    1.90 +/**
    1.91 + * Custom UTF-8 collating sequence that respects the application's locale.
    1.92 + * Comparison is case-insensitive and accent-sensitive.  This is called by
    1.93 + * SQLite.
    1.94 + *
    1.95 + * @param  aService
    1.96 + *         The Service that owns the nsICollation used by this collation.
    1.97 + * @param  aLen1
    1.98 + *         The number of bytes in aStr1.
    1.99 + * @param  aStr1
   1.100 + *         The string to be compared against aStr2.  It will be passed in by
   1.101 + *         SQLite as a non-null-terminated char* buffer.
   1.102 + * @param  aLen2
   1.103 + *         The number of bytes in aStr2.
   1.104 + * @param  aStr2
   1.105 + *         The string to be compared against aStr1.  It will be passed in by
   1.106 + *         SQLite as a non-null-terminated char* buffer.
   1.107 + * @return aStr1 - aStr2.  That is, if aStr1 < aStr2, returns a negative number.
   1.108 + *         If aStr1 > aStr2, returns a positive number.  If aStr1 == aStr2,
   1.109 + *         returns 0.
   1.110 + */
   1.111 +NS_HIDDEN_(int) localeCollationAccentSensitive8(void *aService,
   1.112 +                                                int aLen1,
   1.113 +                                                const void *aStr1,
   1.114 +                                                int aLen2,
   1.115 +                                                const void *aStr2);
   1.116 +
   1.117 +/**
   1.118 + * Custom UTF-8 collating sequence that respects the application's locale.
   1.119 + * Comparison is case- and accent-sensitive.  This is called by SQLite.
   1.120 + *
   1.121 + * @param  aService
   1.122 + *         The Service that owns the nsICollation used by this collation.
   1.123 + * @param  aLen1
   1.124 + *         The number of bytes in aStr1.
   1.125 + * @param  aStr1
   1.126 + *         The string to be compared against aStr2.  It will be passed in by
   1.127 + *         SQLite as a non-null-terminated char* buffer.
   1.128 + * @param  aLen2
   1.129 + *         The number of bytes in aStr2.
   1.130 + * @param  aStr2
   1.131 + *         The string to be compared against aStr1.  It will be passed in by
   1.132 + *         SQLite as a non-null-terminated char* buffer.
   1.133 + * @return aStr1 - aStr2.  That is, if aStr1 < aStr2, returns a negative number.
   1.134 + *         If aStr1 > aStr2, returns a positive number.  If aStr1 == aStr2,
   1.135 + *         returns 0.
   1.136 + */
   1.137 +NS_HIDDEN_(int) localeCollationCaseAccentSensitive8(void *aService,
   1.138 +                                                    int aLen1,
   1.139 +                                                    const void *aStr1,
   1.140 +                                                    int aLen2,
   1.141 +                                                    const void *aStr2);
   1.142 +
   1.143 +/**
   1.144 + * Custom UTF-16 collating sequence that respects the application's locale.
   1.145 + * Comparison is case- and accent-insensitive.  This is called by SQLite.
   1.146 + *
   1.147 + * @param  aService
   1.148 + *         The Service that owns the nsICollation used by this collation.
   1.149 + * @param  aLen1
   1.150 + *         The number of bytes (not characters) in aStr1.
   1.151 + * @param  aStr1
   1.152 + *         The string to be compared against aStr2.  It will be passed in by
   1.153 + *         SQLite as a non-null-terminated char16_t* buffer.
   1.154 + * @param  aLen2
   1.155 + *         The number of bytes (not characters) in aStr2.
   1.156 + * @param  aStr2
   1.157 + *         The string to be compared against aStr1.  It will be passed in by
   1.158 + *         SQLite as a non-null-terminated char16_t* buffer.
   1.159 + * @return aStr1 - aStr2.  That is, if aStr1 < aStr2, returns a negative number.
   1.160 + *         If aStr1 > aStr2, returns a positive number.  If aStr1 == aStr2,
   1.161 + *         returns 0.
   1.162 + */
   1.163 +NS_HIDDEN_(int) localeCollation16(void *aService,
   1.164 +                                  int aLen1,
   1.165 +                                  const void *aStr1,
   1.166 +                                  int aLen2,
   1.167 +                                  const void *aStr2);
   1.168 +
   1.169 +/**
   1.170 + * Custom UTF-16 collating sequence that respects the application's locale.
   1.171 + * Comparison is case-sensitive and accent-insensitive.  This is called by
   1.172 + * SQLite.
   1.173 + *
   1.174 + * @param  aService
   1.175 + *         The Service that owns the nsICollation used by this collation.
   1.176 + * @param  aLen1
   1.177 + *         The number of bytes (not characters) in aStr1.
   1.178 + * @param  aStr1
   1.179 + *         The string to be compared against aStr2.  It will be passed in by
   1.180 + *         SQLite as a non-null-terminated char16_t* buffer.
   1.181 + * @param  aLen2
   1.182 + *         The number of bytes (not characters) in aStr2.
   1.183 + * @param  aStr2
   1.184 + *         The string to be compared against aStr1.  It will be passed in by
   1.185 + *         SQLite as a non-null-terminated char16_t* buffer.
   1.186 + * @return aStr1 - aStr2.  That is, if aStr1 < aStr2, returns a negative number.
   1.187 + *         If aStr1 > aStr2, returns a positive number.  If aStr1 == aStr2,
   1.188 + *         returns 0.
   1.189 + */
   1.190 +NS_HIDDEN_(int) localeCollationCaseSensitive16(void *aService,
   1.191 +                                               int aLen1,
   1.192 +                                               const void *aStr1,
   1.193 +                                               int aLen2,
   1.194 +                                               const void *aStr2);
   1.195 +
   1.196 +/**
   1.197 + * Custom UTF-16 collating sequence that respects the application's locale.
   1.198 + * Comparison is case-insensitive and accent-sensitive.  This is called by
   1.199 + * SQLite.
   1.200 + *
   1.201 + * @param  aService
   1.202 + *         The Service that owns the nsICollation used by this collation.
   1.203 + * @param  aLen1
   1.204 + *         The number of bytes (not characters) in aStr1.
   1.205 + * @param  aStr1
   1.206 + *         The string to be compared against aStr2.  It will be passed in by
   1.207 + *         SQLite as a non-null-terminated char16_t* buffer.
   1.208 + * @param  aLen2
   1.209 + *         The number of bytes (not characters) in aStr2.
   1.210 + * @param  aStr2
   1.211 + *         The string to be compared against aStr1.  It will be passed in by
   1.212 + *         SQLite as a non-null-terminated char16_t* buffer.
   1.213 + * @return aStr1 - aStr2.  That is, if aStr1 < aStr2, returns a negative number.
   1.214 + *         If aStr1 > aStr2, returns a positive number.  If aStr1 == aStr2,
   1.215 + *         returns 0.
   1.216 + */
   1.217 +NS_HIDDEN_(int) localeCollationAccentSensitive16(void *aService,
   1.218 +                                                 int aLen1,
   1.219 +                                                 const void *aStr1,
   1.220 +                                                 int aLen2,
   1.221 +                                                 const void *aStr2);
   1.222 +
   1.223 +/**
   1.224 + * Custom UTF-16 collating sequence that respects the application's locale.
   1.225 + * Comparison is case- and accent-sensitive.  This is called by SQLite.
   1.226 + *
   1.227 + * @param  aService
   1.228 + *         The Service that owns the nsICollation used by this collation.
   1.229 + * @param  aLen1
   1.230 + *         The number of bytes (not characters) in aStr1.
   1.231 + * @param  aStr1
   1.232 + *         The string to be compared against aStr2.  It will be passed in by
   1.233 + *         SQLite as a non-null-terminated char16_t* buffer.
   1.234 + * @param  aLen2
   1.235 + *         The number of bytes (not characters) in aStr2.
   1.236 + * @param  aStr2
   1.237 + *         The string to be compared against aStr1.  It will be passed in by
   1.238 + *         SQLite as a non-null-terminated char16_t* buffer.
   1.239 + * @return aStr1 - aStr2.  That is, if aStr1 < aStr2, returns a negative number.
   1.240 + *         If aStr1 > aStr2, returns a positive number.  If aStr1 == aStr2,
   1.241 + *         returns 0.
   1.242 + */
   1.243 +NS_HIDDEN_(int) localeCollationCaseAccentSensitive16(void *aService,
   1.244 +                                                     int aLen1,
   1.245 +                                                     const void *aStr1,
   1.246 +                                                     int aLen2,
   1.247 +                                                     const void *aStr2);
   1.248 +
   1.249 +} // namespace storage
   1.250 +} // namespace mozilla
   1.251 +
   1.252 +#endif // mozilla_storage_SQLCollations_h

mercurial