michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_storage_SQLCollations_h michael@0: #define mozilla_storage_SQLCollations_h michael@0: michael@0: #include "mozStorageService.h" michael@0: #include "nscore.h" michael@0: #include "nsString.h" michael@0: michael@0: #include "sqlite3.h" michael@0: michael@0: namespace mozilla { michael@0: namespace storage { michael@0: michael@0: /** michael@0: * Registers the collating sequences declared here with the specified michael@0: * database and Service. michael@0: * michael@0: * @param aDB michael@0: * The database we'll be registering the collations with. michael@0: * @param aService michael@0: * The Service that owns the nsICollation used by our collations. michael@0: * @return the SQLite status code indicating success or failure. michael@0: */ michael@0: NS_HIDDEN_(int) registerCollations(sqlite3 *aDB, Service *aService); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: //// Predefined Functions michael@0: michael@0: /** michael@0: * Custom UTF-8 collating sequence that respects the application's locale. michael@0: * Comparison is case- and accent-insensitive. This is called by SQLite. michael@0: * michael@0: * @param aService michael@0: * The Service that owns the nsICollation used by this collation. michael@0: * @param aLen1 michael@0: * The number of bytes in aStr1. michael@0: * @param aStr1 michael@0: * The string to be compared against aStr2. It will be passed in by michael@0: * SQLite as a non-null-terminated char* buffer. michael@0: * @param aLen2 michael@0: * The number of bytes in aStr2. michael@0: * @param aStr2 michael@0: * The string to be compared against aStr1. It will be passed in by michael@0: * SQLite as a non-null-terminated char* buffer. michael@0: * @return aStr1 - aStr2. That is, if aStr1 < aStr2, returns a negative number. michael@0: * If aStr1 > aStr2, returns a positive number. If aStr1 == aStr2, michael@0: * returns 0. michael@0: */ michael@0: NS_HIDDEN_(int) localeCollation8(void *aService, michael@0: int aLen1, michael@0: const void *aStr1, michael@0: int aLen2, michael@0: const void *aStr2); michael@0: michael@0: /** michael@0: * Custom UTF-8 collating sequence that respects the application's locale. michael@0: * Comparison is case-sensitive and accent-insensitive. This is called by michael@0: * SQLite. michael@0: * michael@0: * @param aService michael@0: * The Service that owns the nsICollation used by this collation. michael@0: * @param aLen1 michael@0: * The number of bytes in aStr1. michael@0: * @param aStr1 michael@0: * The string to be compared against aStr2. It will be passed in by michael@0: * SQLite as a non-null-terminated char* buffer. michael@0: * @param aLen2 michael@0: * The number of bytes in aStr2. michael@0: * @param aStr2 michael@0: * The string to be compared against aStr1. It will be passed in by michael@0: * SQLite as a non-null-terminated char* buffer. michael@0: * @return aStr1 - aStr2. That is, if aStr1 < aStr2, returns a negative number. michael@0: * If aStr1 > aStr2, returns a positive number. If aStr1 == aStr2, michael@0: * returns 0. michael@0: */ michael@0: NS_HIDDEN_(int) localeCollationCaseSensitive8(void *aService, michael@0: int aLen1, michael@0: const void *aStr1, michael@0: int aLen2, michael@0: const void *aStr2); michael@0: michael@0: /** michael@0: * Custom UTF-8 collating sequence that respects the application's locale. michael@0: * Comparison is case-insensitive and accent-sensitive. This is called by michael@0: * SQLite. michael@0: * michael@0: * @param aService michael@0: * The Service that owns the nsICollation used by this collation. michael@0: * @param aLen1 michael@0: * The number of bytes in aStr1. michael@0: * @param aStr1 michael@0: * The string to be compared against aStr2. It will be passed in by michael@0: * SQLite as a non-null-terminated char* buffer. michael@0: * @param aLen2 michael@0: * The number of bytes in aStr2. michael@0: * @param aStr2 michael@0: * The string to be compared against aStr1. It will be passed in by michael@0: * SQLite as a non-null-terminated char* buffer. michael@0: * @return aStr1 - aStr2. That is, if aStr1 < aStr2, returns a negative number. michael@0: * If aStr1 > aStr2, returns a positive number. If aStr1 == aStr2, michael@0: * returns 0. michael@0: */ michael@0: NS_HIDDEN_(int) localeCollationAccentSensitive8(void *aService, michael@0: int aLen1, michael@0: const void *aStr1, michael@0: int aLen2, michael@0: const void *aStr2); michael@0: michael@0: /** michael@0: * Custom UTF-8 collating sequence that respects the application's locale. michael@0: * Comparison is case- and accent-sensitive. This is called by SQLite. michael@0: * michael@0: * @param aService michael@0: * The Service that owns the nsICollation used by this collation. michael@0: * @param aLen1 michael@0: * The number of bytes in aStr1. michael@0: * @param aStr1 michael@0: * The string to be compared against aStr2. It will be passed in by michael@0: * SQLite as a non-null-terminated char* buffer. michael@0: * @param aLen2 michael@0: * The number of bytes in aStr2. michael@0: * @param aStr2 michael@0: * The string to be compared against aStr1. It will be passed in by michael@0: * SQLite as a non-null-terminated char* buffer. michael@0: * @return aStr1 - aStr2. That is, if aStr1 < aStr2, returns a negative number. michael@0: * If aStr1 > aStr2, returns a positive number. If aStr1 == aStr2, michael@0: * returns 0. michael@0: */ michael@0: NS_HIDDEN_(int) localeCollationCaseAccentSensitive8(void *aService, michael@0: int aLen1, michael@0: const void *aStr1, michael@0: int aLen2, michael@0: const void *aStr2); michael@0: michael@0: /** michael@0: * Custom UTF-16 collating sequence that respects the application's locale. michael@0: * Comparison is case- and accent-insensitive. This is called by SQLite. michael@0: * michael@0: * @param aService michael@0: * The Service that owns the nsICollation used by this collation. michael@0: * @param aLen1 michael@0: * The number of bytes (not characters) in aStr1. michael@0: * @param aStr1 michael@0: * The string to be compared against aStr2. It will be passed in by michael@0: * SQLite as a non-null-terminated char16_t* buffer. michael@0: * @param aLen2 michael@0: * The number of bytes (not characters) in aStr2. michael@0: * @param aStr2 michael@0: * The string to be compared against aStr1. It will be passed in by michael@0: * SQLite as a non-null-terminated char16_t* buffer. michael@0: * @return aStr1 - aStr2. That is, if aStr1 < aStr2, returns a negative number. michael@0: * If aStr1 > aStr2, returns a positive number. If aStr1 == aStr2, michael@0: * returns 0. michael@0: */ michael@0: NS_HIDDEN_(int) localeCollation16(void *aService, michael@0: int aLen1, michael@0: const void *aStr1, michael@0: int aLen2, michael@0: const void *aStr2); michael@0: michael@0: /** michael@0: * Custom UTF-16 collating sequence that respects the application's locale. michael@0: * Comparison is case-sensitive and accent-insensitive. This is called by michael@0: * SQLite. michael@0: * michael@0: * @param aService michael@0: * The Service that owns the nsICollation used by this collation. michael@0: * @param aLen1 michael@0: * The number of bytes (not characters) in aStr1. michael@0: * @param aStr1 michael@0: * The string to be compared against aStr2. It will be passed in by michael@0: * SQLite as a non-null-terminated char16_t* buffer. michael@0: * @param aLen2 michael@0: * The number of bytes (not characters) in aStr2. michael@0: * @param aStr2 michael@0: * The string to be compared against aStr1. It will be passed in by michael@0: * SQLite as a non-null-terminated char16_t* buffer. michael@0: * @return aStr1 - aStr2. That is, if aStr1 < aStr2, returns a negative number. michael@0: * If aStr1 > aStr2, returns a positive number. If aStr1 == aStr2, michael@0: * returns 0. michael@0: */ michael@0: NS_HIDDEN_(int) localeCollationCaseSensitive16(void *aService, michael@0: int aLen1, michael@0: const void *aStr1, michael@0: int aLen2, michael@0: const void *aStr2); michael@0: michael@0: /** michael@0: * Custom UTF-16 collating sequence that respects the application's locale. michael@0: * Comparison is case-insensitive and accent-sensitive. This is called by michael@0: * SQLite. michael@0: * michael@0: * @param aService michael@0: * The Service that owns the nsICollation used by this collation. michael@0: * @param aLen1 michael@0: * The number of bytes (not characters) in aStr1. michael@0: * @param aStr1 michael@0: * The string to be compared against aStr2. It will be passed in by michael@0: * SQLite as a non-null-terminated char16_t* buffer. michael@0: * @param aLen2 michael@0: * The number of bytes (not characters) in aStr2. michael@0: * @param aStr2 michael@0: * The string to be compared against aStr1. It will be passed in by michael@0: * SQLite as a non-null-terminated char16_t* buffer. michael@0: * @return aStr1 - aStr2. That is, if aStr1 < aStr2, returns a negative number. michael@0: * If aStr1 > aStr2, returns a positive number. If aStr1 == aStr2, michael@0: * returns 0. michael@0: */ michael@0: NS_HIDDEN_(int) localeCollationAccentSensitive16(void *aService, michael@0: int aLen1, michael@0: const void *aStr1, michael@0: int aLen2, michael@0: const void *aStr2); michael@0: michael@0: /** michael@0: * Custom UTF-16 collating sequence that respects the application's locale. michael@0: * Comparison is case- and accent-sensitive. This is called by SQLite. michael@0: * michael@0: * @param aService michael@0: * The Service that owns the nsICollation used by this collation. michael@0: * @param aLen1 michael@0: * The number of bytes (not characters) in aStr1. michael@0: * @param aStr1 michael@0: * The string to be compared against aStr2. It will be passed in by michael@0: * SQLite as a non-null-terminated char16_t* buffer. michael@0: * @param aLen2 michael@0: * The number of bytes (not characters) in aStr2. michael@0: * @param aStr2 michael@0: * The string to be compared against aStr1. It will be passed in by michael@0: * SQLite as a non-null-terminated char16_t* buffer. michael@0: * @return aStr1 - aStr2. That is, if aStr1 < aStr2, returns a negative number. michael@0: * If aStr1 > aStr2, returns a positive number. If aStr1 == aStr2, michael@0: * returns 0. michael@0: */ michael@0: NS_HIDDEN_(int) localeCollationCaseAccentSensitive16(void *aService, michael@0: int aLen1, michael@0: const void *aStr1, michael@0: int aLen2, michael@0: const void *aStr2); michael@0: michael@0: } // namespace storage michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_storage_SQLCollations_h