From 4ba4259df72d3c2d694db044ceef2530092969c4 Mon Sep 17 00:00:00 2001 From: Alan Liu Date: Fri, 20 Feb 2004 03:32:06 +0000 Subject: [PATCH] ICU-3078 add StringEnumeration* getAvailableIDs(); mark countAvailableIDs() and getAvailableID() as obsolete X-SVN-Rev: 14553 --- icu4c/source/i18n/translit.cpp | 18 +++++++++++ icu4c/source/i18n/unicode/translit.h | 48 +++++++++++++++++----------- 2 files changed, 48 insertions(+), 18 deletions(-) diff --git a/icu4c/source/i18n/translit.cpp b/icu4c/source/i18n/translit.cpp index 78ec911e6c3..8987fdc2a24 100644 --- a/icu4c/source/i18n/translit.cpp +++ b/icu4c/source/i18n/translit.cpp @@ -22,6 +22,7 @@ #include "unicode/unifltlg.h" #include "unicode/uniset.h" #include "unicode/uscript.h" +#include "unicode/strenum.h" #include "cpdtrans.h" #include "nultrans.h" #include "rbt_data.h" @@ -1188,6 +1189,7 @@ void Transliterator::unregister(const UnicodeString& ID) { } /** + * == OBSOLETE - remove in ICU 3.4 == * Return the number of IDs currently registered with the system. * To retrieve the actual IDs, call getAvailableID(i) with * i from 0 to countAvailableIDs() - 1. @@ -1199,6 +1201,7 @@ int32_t Transliterator::countAvailableIDs(void) { } /** + * == OBSOLETE - remove in ICU 3.4 == * Return the index-th available ID. index must be between 0 * and countAvailableIDs() - 1, inclusive. If index is out of * range, the result of getAvailableID(0) is returned. @@ -1215,6 +1218,21 @@ const UnicodeString& Transliterator::getAvailableID(int32_t index) { return *result; } +StringEnumeration* Transliterator::getAvailableIDs(UErrorCode& ec) { + if (U_FAILURE(ec)) return NULL; + StringEnumeration* result = NULL; + umtx_init(®istryMutex); + umtx_lock(®istryMutex); + if (HAVE_REGISTRY) { + result = registry->getAvailableIDs(); + } + umtx_unlock(®istryMutex); + if (result == NULL) { + ec = U_INTERNAL_TRANSLITERATOR_ERROR; + } + return result; +} + int32_t Transliterator::countAvailableSources(void) { umtx_init(®istryMutex); Mutex lock(®istryMutex); diff --git a/icu4c/source/i18n/unicode/translit.h b/icu4c/source/i18n/unicode/translit.h index 9a65e95d965..090070e0f00 100644 --- a/icu4c/source/i18n/unicode/translit.h +++ b/icu4c/source/i18n/unicode/translit.h @@ -18,6 +18,7 @@ #include "unicode/unistr.h" #include "unicode/parseerr.h" #include "unicode/utrans.h" // UTransPosition, UTransDirection +#include "unicode/strenum.h" U_NAMESPACE_BEGIN @@ -1031,25 +1032,15 @@ public: public: /** - * Return the number of IDs currently registered with the system. - * To retrieve the actual IDs, call getAvailableID(i) with - * i from 0 to countAvailableIDs() - 1. - * @return the number of IDs currently registered with the system. - * @stable ICU 2.0 + * Return a StringEnumeration over the IDs available at the time of the + * call, including user-registered IDs. + * @param ec input-output error code + * @return a newly-created StringEnumeration over the transliterators + * available at the time of the call. The caller should delete this object + * when done using it. + * @draft ICU 3.0 */ - static int32_t countAvailableIDs(void); - - /** - * Return the index-th available ID. index must be between 0 - * and countAvailableIDs() - 1, inclusive. If index is out of - * range, the result of getAvailableID(0) is returned. - * @param index the given ID index. - * @return the index-th available ID. index must be between 0 - * and countAvailableIDs() - 1, inclusive. If index is out of - * range, the result of getAvailableID(0) is returned. - * @stable ICU 2.0 - */ - static const UnicodeString& getAvailableID(int32_t index); + static StringEnumeration* getAvailableIDs(UErrorCode& ec); /** * Return the number of registered source specifiers. @@ -1203,6 +1194,27 @@ public: private: static UBool initializeRegistry(void); +public: + /** + * Return the number of IDs currently registered with the system. + * To retrieve the actual IDs, call getAvailableID(i) with + * i from 0 to countAvailableIDs() - 1. + * @return the number of IDs currently registered with the system. + * @obsolete ICU 3.4 use getAvailableIDs() instead + */ + static int32_t countAvailableIDs(void); + + /** + * Return the index-th available ID. index must be between 0 + * and countAvailableIDs() - 1, inclusive. If index is out of + * range, the result of getAvailableID(0) is returned. + * @param index the given ID index. + * @return the index-th available ID. index must be between 0 + * and countAvailableIDs() - 1, inclusive. If index is out of + * range, the result of getAvailableID(0) is returned. + * @obsolete ICU 3.4 use getAvailableIDs() instead + */ + static const UnicodeString& getAvailableID(int32_t index); }; inline int32_t Transliterator::getMaximumContextLength(void) const {