X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/73c04bcfe1096173b00431f0cdc742894b15eef0..38fbf2fd31f5cd99b500914d6037b1d06b608645:/icuSources/i18n/unicode/translit.h diff --git a/icuSources/i18n/unicode/translit.h b/icuSources/i18n/unicode/translit.h index 117325ff..4830da82 100644 --- a/icuSources/i18n/unicode/translit.h +++ b/icuSources/i18n/unicode/translit.h @@ -1,6 +1,8 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ********************************************************************** -* Copyright (C) 1999-2006, International Business Machines +* Copyright (C) 1999-2014, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Date Name Description @@ -25,6 +27,7 @@ #include "unicode/utrans.h" // UTransPosition, UTransDirection #include "unicode/strenum.h" +#if U_SHOW_CPLUSPLUS_API U_NAMESPACE_BEGIN class UnicodeFilter; @@ -59,7 +62,7 @@ class TransliteratorIDParser; * transliterate(). (However, this does not * mean that threads may share transliterators without synchronizing * them. Transliterators are not immutable, so they must be - * synchronized when shared between threads.) This1 might seem to + * synchronized when shared between threads.) This might seem to * limit the complexity of the transliteration operation. In * practice, subclasses perform complex transliterations by delaying * the replacement of text until it is known that no other @@ -277,6 +280,7 @@ private: void* pointer; }; +#ifndef U_HIDE_INTERNAL_API /** * Return a token containing an integer. * @return a token containing an integer. @@ -290,6 +294,7 @@ private: * @internal */ inline static Token pointerToken(void*); +#endif /* U_HIDE_INTERNAL_API */ /** * A function that creates and returns a Transliterator. When @@ -349,7 +354,7 @@ protected: friend class TransliteratorParser; // for parseID() friend class TransliteratorIDParser; // for createBasicInstance() - friend class TransliteratorAlias; // for setID() + friend class TransliteratorAlias; // for setID() public: @@ -472,13 +477,10 @@ public: * Transliterates the portion of the text buffer that can be * transliterated unambiguosly after a new character has been * inserted, typically as a result of a keyboard event. This is a - * convenience method; see {@link - * #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode&) const} - * for details. + * convenience method. * @param text the buffer holding transliterated and * untransliterated text - * @param index an array of three integers. See {@link - * #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode&) const }. + * @param index an array of three integers. * @param insertion text to be inserted and possibly * transliterated into the translation buffer at * index.limit. @@ -498,8 +500,7 @@ public: * for details. * @param text the buffer holding transliterated and * untransliterated text - * @param index an array of three integers. See {@link - * #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode&) const }. + * @param index an array of three integers. See {@link #transliterate(Replaceable&, UTransPosition&, const UnicodeString*, UErrorCode&) const }. * @param status Output param to filled in with a success or an error. * @see #transliterate(Replaceable, int[], String) * @stable ICU 2.0 @@ -607,7 +608,7 @@ protected: * applying the filter. End user code should call * transliterate() instead of this method. Subclass code * and wrapping transliterators should call - * filteredTransliterate() instead of this method.

+ * filteredTransliterate() instead of this method.

* * @param text the buffer holding transliterated and * untransliterated text @@ -629,7 +630,7 @@ protected: UBool incremental) const = 0; public: - /** + /** * Transliterate a substring of text, as specified by index, taking filters * into account. This method is for subclasses that need to delegate to * another transliterator, such as CompoundTransliterator. @@ -655,7 +656,7 @@ private: * *

If this transliterator has a filter, break up the input text into runs * of unfiltered characters. Pass each run to - * .handleTransliterate(). + * subclass.handleTransliterate(). * *

In incremental mode, if rollback is TRUE, perform a special * incremental procedure in which several passes are made over the input @@ -967,6 +968,11 @@ public: /** * Registers a factory function that creates transliterators of * a given ID. + * + * Because ICU may choose to cache Transliterators internally, this must + * be called at application startup, prior to any calls to + * Transliterator::createXXX to avoid undefined behavior. + * * @param id the ID being registered * @param factory a function pointer that will be copied and * called later when the given ID is passed to createInstance() @@ -989,6 +995,10 @@ public: * After this call the Transliterator class owns the adoptedObj * and will delete it. * + * Because ICU may choose to cache Transliterators internally, this must + * be called at application startup, prior to any calls to + * Transliterator::createXXX to avoid undefined behavior. + * * @param adoptedObj an instance of subclass of * Transliterator that defines clone() * @see #createInstance @@ -1010,21 +1020,22 @@ public: * This can be a compound ID and can include filters and should * refer to transliterators that have already been registered with * the framework, although this isn't checked. - * @draft ICU 3.6 + * @stable ICU 3.6 */ static void U_EXPORT2 registerAlias(const UnicodeString& aliasID, - const UnicodeString& realID); + const UnicodeString& realID); protected: +#ifndef U_HIDE_INTERNAL_API /** - * @internal * @param id the ID being registered * @param factory a function pointer that will be copied and * called later when the given ID is passed to createInstance() * @param context a context pointer that will be stored and * later passed to the factory function when an ID matching * the registration ID is being instantiated with this factory. + * @internal */ static void _registerFactory(const UnicodeString& id, Factory factory, @@ -1035,10 +1046,10 @@ protected: */ static void _registerInstance(Transliterator* adoptedObj); - /** - * @internal - */ - static void _registerAlias(const UnicodeString& aliasID, const UnicodeString& realID); + /** + * @internal + */ + static void _registerAlias(const UnicodeString& aliasID, const UnicodeString& realID); /** * Register two targets as being inverses of one another. For @@ -1076,6 +1087,7 @@ protected: static void _registerSpecialInverse(const UnicodeString& target, const UnicodeString& inverseTarget, UBool bidirectional); +#endif /* U_HIDE_INTERNAL_API */ public: @@ -1085,6 +1097,10 @@ public: * Any attempt to construct an unregistered transliterator based * on its ID will fail. * + * Because ICU may choose to cache Transliterators internally, this should + * be called during application shutdown, after all calls to + * Transliterator::createXXX to avoid undefined behavior. + * * @param ID the ID of the transliterator or class * @return the Object that was registered with * ID, or null if none was @@ -1181,6 +1197,7 @@ public: protected: +#ifndef U_HIDE_INTERNAL_API /** * Non-mutexed internal method * @internal @@ -1223,6 +1240,7 @@ protected: const UnicodeString& source, const UnicodeString& target, UnicodeString& result); +#endif /* U_HIDE_INTERNAL_API */ protected: @@ -1266,9 +1284,10 @@ public: virtual UClassID getDynamicClassID(void) const = 0; private: - static UBool initializeRegistry(void); + static UBool initializeRegistry(UErrorCode &status); public: +#ifndef U_HIDE_OBSOLETE_API /** * Return the number of IDs currently registered with the system. * To retrieve the actual IDs, call getAvailableID(i) with @@ -1291,6 +1310,7 @@ public: * may become invalid if another thread calls unregister */ static const UnicodeString& U_EXPORT2 getAvailableID(int32_t index); +#endif /* U_HIDE_OBSOLETE_API */ }; inline int32_t Transliterator::getMaximumContextLength(void) const { @@ -1300,10 +1320,11 @@ inline int32_t Transliterator::getMaximumContextLength(void) const { inline void Transliterator::setID(const UnicodeString& id) { ID = id; // NUL-terminate the ID string, which is a non-aliased copy. - ID.append((UChar)0); + ID.append((char16_t)0); ID.truncate(ID.length()-1); } +#ifndef U_HIDE_INTERNAL_API inline Transliterator::Token Transliterator::integerToken(int32_t i) { Token t; t.integer = i; @@ -1315,8 +1336,10 @@ inline Transliterator::Token Transliterator::pointerToken(void* p) { t.pointer = p; return t; } +#endif /* U_HIDE_INTERNAL_API */ U_NAMESPACE_END +#endif // U_SHOW_CPLUSPLUS_API #endif /* #if !UCONFIG_NO_TRANSLITERATION */