michael@0: /* -*- Mode: idl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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: #include "nsILocale.idl" michael@0: michael@0: interface nsICollation; michael@0: michael@0: [scriptable, uuid(04971e14-d6b3-4ada-8cbb-c3a13842b349)] michael@0: interface nsICollationFactory : nsISupports michael@0: { michael@0: /** michael@0: * Create the collation for a given locale. michael@0: * michael@0: * Use NULL as the locale parameter to use the user's locale preference michael@0: * from the operating system. michael@0: * michael@0: * @param locale michael@0: * The locale for which to create the collation or null to use michael@0: * user preference. michael@0: * @return A collation for the given locale. michael@0: */ michael@0: nsICollation CreateCollation(in nsILocale locale); michael@0: }; michael@0: michael@0: [scriptable, uuid(b0132cc0-3786-4557-9874-910d7def5f93)] michael@0: interface nsICollation : nsISupports { michael@0: michael@0: // use the primary comparison for the given locale - no flags michael@0: const long kCollationStrengthDefault = 0; michael@0: michael@0: // do not consider case differences when doing the comparison i.e. A=a) michael@0: const long kCollationCaseInsensitiveAscii = 1; michael@0: michael@0: // do not consider accent differences when doing the comparison a=รก) michael@0: const long kCollationAccentInsenstive = 2; michael@0: michael@0: // case sensitive collation (default) michael@0: const long kCollationCaseSensitive = kCollationStrengthDefault; michael@0: michael@0: // case insensitive collation michael@0: const long kCollationCaseInSensitive = (kCollationCaseInsensitiveAscii | kCollationAccentInsenstive); michael@0: michael@0: // init this interface to a specified locale (should only be called by collation factory) michael@0: void initialize(in nsILocale locale); michael@0: michael@0: // compare two strings michael@0: // result is same as strcmp michael@0: long compareString(in long strength, in AString string1, in AString string2); michael@0: michael@0: // allocate sort key from input string michael@0: // returns newly allocated key, and its band its byte length michael@0: [noscript] void allocateRawSortKey(in long strength, michael@0: in AString stringIn, michael@0: [array,size_is(outLen)] out octet key, michael@0: out unsigned long outLen); michael@0: michael@0: // compare two sort keys michael@0: // length is a byte length, result is same as strcmp michael@0: [noscript] long compareRawSortKey([const,array,size_is(len1)] in octet key1, in unsigned long len1, michael@0: [const,array,size_is(len2)] in octet key2, in unsigned long len2); michael@0: michael@0: };