ucol_imp.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. *******************************************************************************
  5. *
  6. * Copyright (C) 1998-2014, International Business Machines
  7. * Corporation and others. All Rights Reserved.
  8. *
  9. *******************************************************************************
  10. *
  11. * Private implementation header for C collation
  12. * file name: ucol_imp.h
  13. * encoding: UTF-8
  14. * tab size: 8 (not used)
  15. * indentation:4
  16. *
  17. * created on: 2000dec11
  18. * created by: Vladimir Weinstein
  19. *
  20. * Modification history
  21. * Date Name Comments
  22. * 02/16/2001 synwee Added UCOL_GETPREVCE for the use in ucoleitr
  23. * 02/27/2001 synwee Added getMaxExpansion data structure in UCollator
  24. * 03/02/2001 synwee Added UCOL_IMPLICIT_CE
  25. * 03/12/2001 synwee Added pointer start to collIterate.
  26. */
  27. #ifndef UCOL_IMP_H
  28. #define UCOL_IMP_H
  29. #include "unicode/utypes.h"
  30. #if !UCONFIG_NO_COLLATION
  31. // This part needs to compile as plain C code, for cintltst.
  32. #include "unicode/ucol.h"
  33. /** Check whether two collators are equal. Collators are considered equal if they
  34. * will sort strings the same. This means that both the current attributes and the
  35. * rules must be equivalent.
  36. * @param source first collator
  37. * @param target second collator
  38. * @return true or false
  39. * @internal ICU 3.0
  40. */
  41. U_CAPI UBool U_EXPORT2
  42. ucol_equals(const UCollator *source, const UCollator *target);
  43. /**
  44. * Convenience string denoting the Collation data tree
  45. */
  46. #define U_ICUDATA_COLL U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "coll"
  47. #ifdef __cplusplus
  48. #include "unicode/locid.h"
  49. #include "unicode/ures.h"
  50. U_NAMESPACE_BEGIN
  51. struct CollationCacheEntry;
  52. class Locale;
  53. class UnicodeString;
  54. class UnifiedCache;
  55. /** Implemented in ucol_res.cpp. */
  56. class CollationLoader {
  57. public:
  58. static void appendRootRules(UnicodeString &s);
  59. static void loadRules(const char *localeID, const char *collationType,
  60. UnicodeString &rules, UErrorCode &errorCode);
  61. // Adds a reference to returned value.
  62. static const CollationCacheEntry *loadTailoring(const Locale &locale, UErrorCode &errorCode);
  63. // Cache callback. Adds a reference to returned value.
  64. const CollationCacheEntry *createCacheEntry(UErrorCode &errorCode);
  65. private:
  66. static void U_CALLCONV loadRootRules(UErrorCode &errorCode);
  67. // The following members are used by loadTailoring()
  68. // and the cache callback.
  69. static const uint32_t TRIED_SEARCH = 1;
  70. static const uint32_t TRIED_DEFAULT = 2;
  71. static const uint32_t TRIED_STANDARD = 4;
  72. CollationLoader(const CollationCacheEntry *re, const Locale &requested, UErrorCode &errorCode);
  73. ~CollationLoader();
  74. // All loadFromXXX methods add a reference to the returned value.
  75. const CollationCacheEntry *loadFromLocale(UErrorCode &errorCode);
  76. const CollationCacheEntry *loadFromBundle(UErrorCode &errorCode);
  77. const CollationCacheEntry *loadFromCollations(UErrorCode &errorCode);
  78. const CollationCacheEntry *loadFromData(UErrorCode &errorCode);
  79. // Adds a reference to returned value.
  80. const CollationCacheEntry *getCacheEntry(UErrorCode &errorCode);
  81. /**
  82. * Returns the rootEntry (with one addRef()) if loc==root,
  83. * or else returns a new cache entry with ref count 1 for the loc and
  84. * the root tailoring.
  85. */
  86. const CollationCacheEntry *makeCacheEntryFromRoot(
  87. const Locale &loc, UErrorCode &errorCode) const;
  88. /**
  89. * Returns the entryFromCache as is if loc==validLocale,
  90. * or else returns a new cache entry with ref count 1 for the loc and
  91. * the same tailoring. In the latter case, a ref count is removed from
  92. * entryFromCache.
  93. */
  94. static const CollationCacheEntry *makeCacheEntry(
  95. const Locale &loc,
  96. const CollationCacheEntry *entryFromCache,
  97. UErrorCode &errorCode);
  98. const UnifiedCache *cache;
  99. const CollationCacheEntry *rootEntry;
  100. Locale validLocale;
  101. Locale locale;
  102. char type[16];
  103. char defaultType[16];
  104. uint32_t typesTried;
  105. UBool typeFallback;
  106. UResourceBundle *bundle;
  107. UResourceBundle *collations;
  108. UResourceBundle *data;
  109. };
  110. U_NAMESPACE_END
  111. #endif /* __cplusplus */
  112. #endif /* #if !UCONFIG_NO_COLLATION */
  113. #endif