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