intl/icu/source/i18n/anytrans.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 ***********************************************************************
michael@0 3 * Copyright (c) 2002-2007, International Business Machines Corporation
michael@0 4 * and others. All Rights Reserved.
michael@0 5 ***********************************************************************
michael@0 6 * Date Name Description
michael@0 7 * 06/06/2002 aliu Creation.
michael@0 8 ***********************************************************************
michael@0 9 */
michael@0 10 #ifndef _ANYTRANS_H_
michael@0 11 #define _ANYTRANS_H_
michael@0 12
michael@0 13 #include "unicode/utypes.h"
michael@0 14
michael@0 15 #if !UCONFIG_NO_TRANSLITERATION
michael@0 16
michael@0 17 #include "unicode/translit.h"
michael@0 18 #include "unicode/uscript.h"
michael@0 19 #include "uhash.h"
michael@0 20
michael@0 21 U_NAMESPACE_BEGIN
michael@0 22
michael@0 23 /**
michael@0 24 * A transliterator named Any-T or Any-T/V, where T is the target
michael@0 25 * script and V is the optional variant, that uses multiple
michael@0 26 * transliterators, all going to T or T/V, all with script sources.
michael@0 27 * The target must be a script. It partitions text into runs of the
michael@0 28 * same script, and then based on the script of each run,
michael@0 29 * transliterates from that script to the given target or
michael@0 30 * target/variant. Adjacent COMMON or INHERITED script characters are
michael@0 31 * included in each run.
michael@0 32 *
michael@0 33 * @author Alan Liu
michael@0 34 */
michael@0 35 class AnyTransliterator : public Transliterator {
michael@0 36
michael@0 37 /**
michael@0 38 * Cache mapping UScriptCode values to Transliterator*.
michael@0 39 */
michael@0 40 UHashtable* cache;
michael@0 41
michael@0 42 /**
michael@0 43 * The target or target/variant string.
michael@0 44 */
michael@0 45 UnicodeString target;
michael@0 46
michael@0 47 /**
michael@0 48 * The target script code. Never USCRIPT_INVALID_CODE.
michael@0 49 */
michael@0 50 UScriptCode targetScript;
michael@0 51
michael@0 52 public:
michael@0 53
michael@0 54 /**
michael@0 55 * Destructor.
michael@0 56 */
michael@0 57 virtual ~AnyTransliterator();
michael@0 58
michael@0 59 /**
michael@0 60 * Copy constructor.
michael@0 61 */
michael@0 62 AnyTransliterator(const AnyTransliterator&);
michael@0 63
michael@0 64 /**
michael@0 65 * Transliterator API.
michael@0 66 */
michael@0 67 virtual Transliterator* clone() const;
michael@0 68
michael@0 69 /**
michael@0 70 * Implements {@link Transliterator#handleTransliterate}.
michael@0 71 */
michael@0 72 virtual void handleTransliterate(Replaceable& text, UTransPosition& index,
michael@0 73 UBool incremental) const;
michael@0 74
michael@0 75 /**
michael@0 76 * ICU "poor man's RTTI", returns a UClassID for the actual class.
michael@0 77 */
michael@0 78 virtual UClassID getDynamicClassID() const;
michael@0 79
michael@0 80 /**
michael@0 81 * ICU "poor man's RTTI", returns a UClassID for this class.
michael@0 82 */
michael@0 83 U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
michael@0 84
michael@0 85 private:
michael@0 86
michael@0 87 /**
michael@0 88 * Private constructor
michael@0 89 * @param id the ID of the form S-T or S-T/V, where T is theTarget
michael@0 90 * and V is theVariant. Must not be empty.
michael@0 91 * @param theTarget the target name. Must not be empty, and must
michael@0 92 * name a script corresponding to theTargetScript.
michael@0 93 * @param theVariant the variant name, or the empty string if
michael@0 94 * there is no variant
michael@0 95 * @param theTargetScript the script code corresponding to
michael@0 96 * theTarget.
michael@0 97 * @param ec error code, fails if the internal hashtable cannot be
michael@0 98 * allocated
michael@0 99 */
michael@0 100 AnyTransliterator(const UnicodeString& id,
michael@0 101 const UnicodeString& theTarget,
michael@0 102 const UnicodeString& theVariant,
michael@0 103 UScriptCode theTargetScript,
michael@0 104 UErrorCode& ec);
michael@0 105
michael@0 106 /**
michael@0 107 * Returns a transliterator from the given source to our target or
michael@0 108 * target/variant. Returns NULL if the source is the same as our
michael@0 109 * target script, or if the source is USCRIPT_INVALID_CODE.
michael@0 110 * Caches the result and returns the same transliterator the next
michael@0 111 * time. The caller does NOT own the result and must not delete
michael@0 112 * it.
michael@0 113 */
michael@0 114 Transliterator* getTransliterator(UScriptCode source) const;
michael@0 115
michael@0 116 /**
michael@0 117 * Registers standard transliterators with the system. Called by
michael@0 118 * Transliterator during initialization.
michael@0 119 */
michael@0 120 static void registerIDs();
michael@0 121
michael@0 122 friend class Transliterator; // for registerIDs()
michael@0 123 };
michael@0 124
michael@0 125 U_NAMESPACE_END
michael@0 126
michael@0 127 #endif /* #if !UCONFIG_NO_TRANSLITERATION */
michael@0 128
michael@0 129 #endif

mercurial