Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* -*- Mode: idl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsILocale.idl" |
michael@0 | 7 | |
michael@0 | 8 | interface nsICollation; |
michael@0 | 9 | |
michael@0 | 10 | [scriptable, uuid(04971e14-d6b3-4ada-8cbb-c3a13842b349)] |
michael@0 | 11 | interface nsICollationFactory : nsISupports |
michael@0 | 12 | { |
michael@0 | 13 | /** |
michael@0 | 14 | * Create the collation for a given locale. |
michael@0 | 15 | * |
michael@0 | 16 | * Use NULL as the locale parameter to use the user's locale preference |
michael@0 | 17 | * from the operating system. |
michael@0 | 18 | * |
michael@0 | 19 | * @param locale |
michael@0 | 20 | * The locale for which to create the collation or null to use |
michael@0 | 21 | * user preference. |
michael@0 | 22 | * @return A collation for the given locale. |
michael@0 | 23 | */ |
michael@0 | 24 | nsICollation CreateCollation(in nsILocale locale); |
michael@0 | 25 | }; |
michael@0 | 26 | |
michael@0 | 27 | [scriptable, uuid(b0132cc0-3786-4557-9874-910d7def5f93)] |
michael@0 | 28 | interface nsICollation : nsISupports { |
michael@0 | 29 | |
michael@0 | 30 | // use the primary comparison for the given locale - no flags |
michael@0 | 31 | const long kCollationStrengthDefault = 0; |
michael@0 | 32 | |
michael@0 | 33 | // do not consider case differences when doing the comparison i.e. A=a) |
michael@0 | 34 | const long kCollationCaseInsensitiveAscii = 1; |
michael@0 | 35 | |
michael@0 | 36 | // do not consider accent differences when doing the comparison a=รก) |
michael@0 | 37 | const long kCollationAccentInsenstive = 2; |
michael@0 | 38 | |
michael@0 | 39 | // case sensitive collation (default) |
michael@0 | 40 | const long kCollationCaseSensitive = kCollationStrengthDefault; |
michael@0 | 41 | |
michael@0 | 42 | // case insensitive collation |
michael@0 | 43 | const long kCollationCaseInSensitive = (kCollationCaseInsensitiveAscii | kCollationAccentInsenstive); |
michael@0 | 44 | |
michael@0 | 45 | // init this interface to a specified locale (should only be called by collation factory) |
michael@0 | 46 | void initialize(in nsILocale locale); |
michael@0 | 47 | |
michael@0 | 48 | // compare two strings |
michael@0 | 49 | // result is same as strcmp |
michael@0 | 50 | long compareString(in long strength, in AString string1, in AString string2); |
michael@0 | 51 | |
michael@0 | 52 | // allocate sort key from input string |
michael@0 | 53 | // returns newly allocated key, and its band its byte length |
michael@0 | 54 | [noscript] void allocateRawSortKey(in long strength, |
michael@0 | 55 | in AString stringIn, |
michael@0 | 56 | [array,size_is(outLen)] out octet key, |
michael@0 | 57 | out unsigned long outLen); |
michael@0 | 58 | |
michael@0 | 59 | // compare two sort keys |
michael@0 | 60 | // length is a byte length, result is same as strcmp |
michael@0 | 61 | [noscript] long compareRawSortKey([const,array,size_is(len1)] in octet key1, in unsigned long len1, |
michael@0 | 62 | [const,array,size_is(len2)] in octet key2, in unsigned long len2); |
michael@0 | 63 | |
michael@0 | 64 | }; |