nsICollation.idl 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #include "nsILocale.idl"
  6. interface nsICollation;
  7. [scriptable, uuid(04971e14-d6b3-4ada-8cbb-c3a13842b349)]
  8. interface nsICollationFactory : nsISupports
  9. {
  10. /**
  11. * Create the collation for a given locale.
  12. *
  13. * Use NULL as the locale parameter to use the user's locale preference
  14. * from the operating system.
  15. *
  16. * @param locale
  17. * The locale for which to create the collation or null to use
  18. * user preference.
  19. * @return A collation for the given locale.
  20. */
  21. nsICollation CreateCollation(in nsILocale locale);
  22. };
  23. [scriptable, uuid(b0132cc0-3786-4557-9874-910d7def5f93)]
  24. interface nsICollation : nsISupports {
  25. // use the primary comparison for the given locale - no flags
  26. const long kCollationStrengthDefault = 0;
  27. // do not consider case differences when doing the comparison i.e. A=a)
  28. const long kCollationCaseInsensitiveAscii = 1;
  29. // do not consider accent differences when doing the comparison a=á)
  30. const long kCollationAccentInsenstive = 2;
  31. // case sensitive collation (default)
  32. const long kCollationCaseSensitive = kCollationStrengthDefault;
  33. // case insensitive collation
  34. const long kCollationCaseInSensitive = (kCollationCaseInsensitiveAscii | kCollationAccentInsenstive);
  35. // init this interface to a specified locale (should only be called by collation factory)
  36. void initialize(in nsILocale locale);
  37. // compare two strings
  38. // result is same as strcmp
  39. long compareString(in long strength, in AString string1, in AString string2);
  40. // allocate sort key from input string
  41. // returns newly allocated key, and its band its byte length
  42. [noscript] void allocateRawSortKey(in long strength,
  43. in AString stringIn,
  44. [array,size_is(outLen)] out octet key,
  45. out unsigned long outLen);
  46. // compare two sort keys
  47. // length is a byte length, result is same as strcmp
  48. [noscript] long compareRawSortKey([const,array,size_is(len1)] in octet key1, in unsigned long len1,
  49. [const,array,size_is(len2)] in octet key2, in unsigned long len2);
  50. };