intl/icu/source/i18n/anytrans.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/i18n/anytrans.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,129 @@
     1.4 +/*
     1.5 +***********************************************************************
     1.6 +* Copyright (c) 2002-2007, International Business Machines Corporation
     1.7 +* and others.  All Rights Reserved.
     1.8 +***********************************************************************
     1.9 +* Date        Name        Description
    1.10 +* 06/06/2002  aliu        Creation.
    1.11 +***********************************************************************
    1.12 +*/
    1.13 +#ifndef _ANYTRANS_H_
    1.14 +#define _ANYTRANS_H_
    1.15 +
    1.16 +#include "unicode/utypes.h"
    1.17 +
    1.18 +#if !UCONFIG_NO_TRANSLITERATION
    1.19 +
    1.20 +#include "unicode/translit.h"
    1.21 +#include "unicode/uscript.h"
    1.22 +#include "uhash.h"
    1.23 +
    1.24 +U_NAMESPACE_BEGIN
    1.25 +
    1.26 +/**
    1.27 + * A transliterator named Any-T or Any-T/V, where T is the target
    1.28 + * script and V is the optional variant, that uses multiple
    1.29 + * transliterators, all going to T or T/V, all with script sources.
    1.30 + * The target must be a script.  It partitions text into runs of the
    1.31 + * same script, and then based on the script of each run,
    1.32 + * transliterates from that script to the given target or
    1.33 + * target/variant.  Adjacent COMMON or INHERITED script characters are
    1.34 + * included in each run.
    1.35 + *
    1.36 + * @author Alan Liu
    1.37 + */
    1.38 +class AnyTransliterator : public Transliterator {
    1.39 +
    1.40 +    /**
    1.41 +     * Cache mapping UScriptCode values to Transliterator*.
    1.42 +     */
    1.43 +    UHashtable* cache;
    1.44 +
    1.45 +    /**
    1.46 +     * The target or target/variant string.
    1.47 +     */
    1.48 +    UnicodeString target;
    1.49 +
    1.50 +    /**
    1.51 +     * The target script code.  Never USCRIPT_INVALID_CODE.
    1.52 +     */
    1.53 +    UScriptCode targetScript;
    1.54 +
    1.55 +public:
    1.56 +
    1.57 +    /**
    1.58 +     * Destructor.
    1.59 +     */
    1.60 +    virtual ~AnyTransliterator();
    1.61 +
    1.62 +    /**
    1.63 +     * Copy constructor.
    1.64 +     */
    1.65 +    AnyTransliterator(const AnyTransliterator&);
    1.66 +
    1.67 +    /**
    1.68 +     * Transliterator API.
    1.69 +     */
    1.70 +    virtual Transliterator* clone() const;
    1.71 +
    1.72 +    /**
    1.73 +     * Implements {@link Transliterator#handleTransliterate}.
    1.74 +     */
    1.75 +    virtual void handleTransliterate(Replaceable& text, UTransPosition& index,
    1.76 +                                     UBool incremental) const;
    1.77 +
    1.78 +    /**
    1.79 +     * ICU "poor man's RTTI", returns a UClassID for the actual class.
    1.80 +     */
    1.81 +    virtual UClassID getDynamicClassID() const;
    1.82 +
    1.83 +    /**
    1.84 +     * ICU "poor man's RTTI", returns a UClassID for this class.
    1.85 +     */
    1.86 +    U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
    1.87 +
    1.88 +private:
    1.89 +
    1.90 +    /**
    1.91 +     * Private constructor
    1.92 +     * @param id the ID of the form S-T or S-T/V, where T is theTarget
    1.93 +     * and V is theVariant.  Must not be empty.
    1.94 +     * @param theTarget the target name.  Must not be empty, and must
    1.95 +     * name a script corresponding to theTargetScript.
    1.96 +     * @param theVariant the variant name, or the empty string if
    1.97 +     * there is no variant
    1.98 +     * @param theTargetScript the script code corresponding to
    1.99 +     * theTarget.
   1.100 +     * @param ec error code, fails if the internal hashtable cannot be
   1.101 +     * allocated
   1.102 +     */
   1.103 +    AnyTransliterator(const UnicodeString& id,
   1.104 +                      const UnicodeString& theTarget,
   1.105 +                      const UnicodeString& theVariant,
   1.106 +                      UScriptCode theTargetScript,
   1.107 +                      UErrorCode& ec);
   1.108 +
   1.109 +    /**
   1.110 +     * Returns a transliterator from the given source to our target or
   1.111 +     * target/variant.  Returns NULL if the source is the same as our
   1.112 +     * target script, or if the source is USCRIPT_INVALID_CODE.
   1.113 +     * Caches the result and returns the same transliterator the next
   1.114 +     * time.  The caller does NOT own the result and must not delete
   1.115 +     * it.
   1.116 +     */
   1.117 +    Transliterator* getTransliterator(UScriptCode source) const;
   1.118 +
   1.119 +    /**
   1.120 +     * Registers standard transliterators with the system.  Called by
   1.121 +     * Transliterator during initialization.
   1.122 +     */
   1.123 +    static void registerIDs();
   1.124 +
   1.125 +    friend class Transliterator; // for registerIDs()
   1.126 +};
   1.127 +
   1.128 +U_NAMESPACE_END
   1.129 +
   1.130 +#endif /* #if !UCONFIG_NO_TRANSLITERATION */
   1.131 +
   1.132 +#endif

mercurial