// © 2016 and later: Unicode, Inc. and others.1// License & terms of use: http://www.unicode.org/copyright.html2/*3***********************************************************************4* Copyright (c) 2002-2007, International Business Machines Corporation5* and others. All Rights Reserved.6***********************************************************************7* Date Name Description8* 06/06/2002 aliu Creation.9***********************************************************************10*/11#ifndef _ANYTRANS_H_12#define _ANYTRANS_H_1314#include "unicode/utypes.h"1516#if !UCONFIG_NO_TRANSLITERATION1718#include "unicode/translit.h"19#include "unicode/uscript.h"20#include "uhash.h"2122U_NAMESPACE_BEGIN2324/**25* A transliterator named Any-T or Any-T/V, where T is the target26* script and V is the optional variant, that uses multiple27* transliterators, all going to T or T/V, all with script sources.28* The target must be a script. It partitions text into runs of the29* same script, and then based on the script of each run,30* transliterates from that script to the given target or31* target/variant. Adjacent COMMON or INHERITED script characters are32* included in each run.33*34* @author Alan Liu35*/36class AnyTransliterator : public Transliterator {3738/**39* Cache mapping UScriptCode values to Transliterator*.40*/41UHashtable* cache;4243/**44* The target or target/variant string.45*/46UnicodeString target;4748/**49* The target script code. Never USCRIPT_INVALID_CODE.50*/51UScriptCode targetScript;5253public:5455/**56* Destructor.57*/58virtual ~AnyTransliterator();5960/**61* Copy constructor.62*/63AnyTransliterator(const AnyTransliterator&);6465/**66* Transliterator API.67*/68virtual AnyTransliterator* clone() const override;6970/**71* Implements {@link Transliterator#handleTransliterate}.72*/73virtual void handleTransliterate(Replaceable& text, UTransPosition& index,74UBool incremental) const override;7576/**77* ICU "poor man's RTTI", returns a UClassID for the actual class.78*/79virtual UClassID getDynamicClassID() const override;8081/**82* ICU "poor man's RTTI", returns a UClassID for this class.83*/84U_I18N_API static UClassID U_EXPORT2 getStaticClassID();8586private:8788/**89* Private constructor90* @param id the ID of the form S-T or S-T/V, where T is theTarget91* and V is theVariant. Must not be empty.92* @param theTarget the target name. Must not be empty, and must93* name a script corresponding to theTargetScript.94* @param theVariant the variant name, or the empty string if95* there is no variant96* @param theTargetScript the script code corresponding to97* theTarget.98* @param ec error code, fails if the internal hashtable cannot be99* allocated100*/101AnyTransliterator(const UnicodeString& id,102const UnicodeString& theTarget,103const UnicodeString& theVariant,104UScriptCode theTargetScript,105UErrorCode& ec);106107/**108* Returns a transliterator from the given source to our target or109* target/variant. Returns NULL if the source is the same as our110* target script, or if the source is USCRIPT_INVALID_CODE.111* Caches the result and returns the same transliterator the next112* time. The caller does NOT own the result and must not delete113* it.114*/115Transliterator* getTransliterator(UScriptCode source) const;116117/**118* Registers standard transliterators with the system. Called by119* Transliterator during initialization.120*/121static void registerIDs();122123friend class Transliterator; // for registerIDs()124};125126U_NAMESPACE_END127128#endif /* #if !UCONFIG_NO_TRANSLITERATION */129130#endif131132133