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