Wed, 31 Dec 2014 06:09:35 +0100
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) 2001-2007, International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ********************************************************************** |
michael@0 | 6 | * Date Name Description |
michael@0 | 7 | * 11/20/2001 aliu Creation. |
michael@0 | 8 | ********************************************************************** |
michael@0 | 9 | */ |
michael@0 | 10 | #ifndef UNESCTRN_H |
michael@0 | 11 | #define UNESCTRN_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 | |
michael@0 | 19 | U_NAMESPACE_BEGIN |
michael@0 | 20 | |
michael@0 | 21 | /** |
michael@0 | 22 | * A transliterator that converts Unicode escape forms to the |
michael@0 | 23 | * characters they represent. Escape forms have a prefix, a suffix, a |
michael@0 | 24 | * radix, and minimum and maximum digit counts. |
michael@0 | 25 | * |
michael@0 | 26 | * <p>This class is package private. It registers several standard |
michael@0 | 27 | * variants with the system which are then accessed via their IDs. |
michael@0 | 28 | * |
michael@0 | 29 | * @author Alan Liu |
michael@0 | 30 | */ |
michael@0 | 31 | class UnescapeTransliterator : public Transliterator { |
michael@0 | 32 | |
michael@0 | 33 | private: |
michael@0 | 34 | |
michael@0 | 35 | /** |
michael@0 | 36 | * The encoded pattern specification. The pattern consists of |
michael@0 | 37 | * zero or more forms. Each form consists of a prefix, suffix, |
michael@0 | 38 | * radix, minimum digit count, and maximum digit count. These |
michael@0 | 39 | * values are stored as a five character header. That is, their |
michael@0 | 40 | * numeric values are cast to 16-bit characters and stored in the |
michael@0 | 41 | * string. Following these five characters, the prefix |
michael@0 | 42 | * characters, then suffix characters are stored. Each form thus |
michael@0 | 43 | * takes n+5 characters, where n is the total length of the prefix |
michael@0 | 44 | * and suffix. The end is marked by a header of length one |
michael@0 | 45 | * consisting of the character END. |
michael@0 | 46 | */ |
michael@0 | 47 | UChar* spec; // owned; may not be NULL |
michael@0 | 48 | |
michael@0 | 49 | public: |
michael@0 | 50 | |
michael@0 | 51 | /** |
michael@0 | 52 | * Registers standard variants with the system. Called by |
michael@0 | 53 | * Transliterator during initialization. |
michael@0 | 54 | */ |
michael@0 | 55 | static void registerIDs(); |
michael@0 | 56 | |
michael@0 | 57 | /** |
michael@0 | 58 | * Constructor. Takes the encoded spec array (does not adopt it). |
michael@0 | 59 | * @param ID the string identifier for this transliterator |
michael@0 | 60 | * @param spec the encoded spec array |
michael@0 | 61 | */ |
michael@0 | 62 | UnescapeTransliterator(const UnicodeString& ID, |
michael@0 | 63 | const UChar *spec); |
michael@0 | 64 | |
michael@0 | 65 | /** |
michael@0 | 66 | * Copy constructor. |
michael@0 | 67 | */ |
michael@0 | 68 | UnescapeTransliterator(const UnescapeTransliterator&); |
michael@0 | 69 | |
michael@0 | 70 | /** |
michael@0 | 71 | * Destructor. |
michael@0 | 72 | */ |
michael@0 | 73 | virtual ~UnescapeTransliterator(); |
michael@0 | 74 | |
michael@0 | 75 | /** |
michael@0 | 76 | * Transliterator API. |
michael@0 | 77 | */ |
michael@0 | 78 | virtual Transliterator* clone() const; |
michael@0 | 79 | |
michael@0 | 80 | /** |
michael@0 | 81 | * ICU "poor man's RTTI", returns a UClassID for the actual class. |
michael@0 | 82 | */ |
michael@0 | 83 | virtual UClassID getDynamicClassID() const; |
michael@0 | 84 | |
michael@0 | 85 | /** |
michael@0 | 86 | * ICU "poor man's RTTI", returns a UClassID for this class. |
michael@0 | 87 | */ |
michael@0 | 88 | U_I18N_API static UClassID U_EXPORT2 getStaticClassID(); |
michael@0 | 89 | |
michael@0 | 90 | protected: |
michael@0 | 91 | |
michael@0 | 92 | /** |
michael@0 | 93 | * Implements {@link Transliterator#handleTransliterate}. |
michael@0 | 94 | * @param text the buffer holding transliterated and |
michael@0 | 95 | * untransliterated text |
michael@0 | 96 | * @param offset the start and limit of the text, the position |
michael@0 | 97 | * of the cursor, and the start and limit of transliteration. |
michael@0 | 98 | * @param incremental if true, assume more text may be coming after |
michael@0 | 99 | * pos.contextLimit. Otherwise, assume the text is complete. |
michael@0 | 100 | */ |
michael@0 | 101 | virtual void handleTransliterate(Replaceable& text, UTransPosition& offset, |
michael@0 | 102 | UBool isIncremental) const; |
michael@0 | 103 | |
michael@0 | 104 | }; |
michael@0 | 105 | |
michael@0 | 106 | U_NAMESPACE_END |
michael@0 | 107 | |
michael@0 | 108 | #endif /* #if !UCONFIG_NO_TRANSLITERATION */ |
michael@0 | 109 | |
michael@0 | 110 | #endif |