1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* 2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru********************************************************************** 3fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius* Copyright (C) 1999-2014, International Business Machines 4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Corporation and others. All Rights Reserved. 5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru********************************************************************** 6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Date Name Description 7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 11/17/99 aliu Creation. 8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru********************************************************************** 9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/ 10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef TRANSLIT_H 11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define TRANSLIT_H 12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utypes.h" 14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/** 16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \file 17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \brief C++ API: Tranforms text from one format to another. 18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_TRANSLITERATION 21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/uobject.h" 23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/unistr.h" 24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/parseerr.h" 25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utrans.h" // UTransPosition, UTransDirection 26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/strenum.h" 27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN 29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass UnicodeFilter; 31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass UnicodeSet; 32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass CompoundTransliterator; 33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass TransliteratorParser; 34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass NormalizationTransliterator; 35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass TransliteratorIDParser; 36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/** 38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>Transliterator</code> is an abstract class that 40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterates text from one format to another. The most common 41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * kind of transliterator is a script, or alphabet, transliterator. 42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For example, a Russian to Latin transliterator changes Russian text 43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * written in Cyrillic characters to phonetically equivalent Latin 44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * characters. It does not <em>translate</em> Russian to English! 45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Transliteration, unlike translation, operates on characters, without 46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * reference to the meanings of words and sentences. 47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Although script conversion is its most common use, a 49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator can actually perform a more general class of tasks. 50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * In fact, <code>Transliterator</code> defines a very general API 51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * which specifies only that a segment of the input text is replaced 52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * by new text. The particulars of this conversion are determined 53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * entirely by subclasses of <code>Transliterator</code>. 54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><b>Transliterators are stateless</b> 56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><code>Transliterator</code> objects are <em>stateless</em>; they 58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * retain no information between calls to 59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>transliterate()</code>. (However, this does <em>not</em> 60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * mean that threads may share transliterators without synchronizing 61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * them. Transliterators are not immutable, so they must be 6285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * synchronized when shared between threads.) This might seem to 63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * limit the complexity of the transliteration operation. In 64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * practice, subclasses perform complex transliterations by delaying 65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the replacement of text until it is known that no other 66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * replacements are possible. In other words, although the 67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>Transliterator</code> objects are stateless, the source text 68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * itself embodies all the needed information, and delayed operation 69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * allows arbitrary complexity. 70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><b>Batch transliteration</b> 72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The simplest way to perform transliteration is all at once, on a 74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * string of existing text. This is referred to as <em>batch</em> 75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliteration. For example, given a string <code>input</code> 76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and a transliterator <code>t</code>, the call 77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \htmlonly<blockquote>\endhtmlonly<code>String result = t.transliterate(input); 79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </code>\htmlonly</blockquote>\endhtmlonly 80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * will transliterate it and return the result. Other methods allow 82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the client to specify a substring to be transliterated and to use 83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * {@link Replaceable } objects instead of strings, in order to 84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * preserve out-of-band information (such as text styles). 85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><b>Keyboard transliteration</b> 87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Somewhat more involved is <em>keyboard</em>, or incremental 89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliteration. This is the transliteration of text that is 90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * arriving from some source (typically the user's keyboard) one 91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * character at a time, or in some other piecemeal fashion. 92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>In keyboard transliteration, a <code>Replaceable</code> buffer 94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * stores the text. As text is inserted, as much as possible is 95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterated on the fly. This means a GUI that displays the 96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * contents of the buffer may show text being modified as each new 97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * character arrives. 98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Consider the simple <code>RuleBasedTransliterator</code>: 100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \htmlonly<blockquote>\endhtmlonly<code> 102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * th>{theta}<br> 103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * t>{tau} 104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </code>\htmlonly</blockquote>\endhtmlonly 105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * When the user types 't', nothing will happen, since the 107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator is waiting to see if the next character is 'h'. To 108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * remedy this, we introduce the notion of a cursor, marked by a '|' 109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * in the output string: 110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \htmlonly<blockquote>\endhtmlonly<code> 112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * t>|{tau}<br> 113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * {tau}h>{theta} 114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </code>\htmlonly</blockquote>\endhtmlonly 115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Now when the user types 't', tau appears, and if the next character 117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is 'h', the tau changes to a theta. This is accomplished by 118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * maintaining a cursor position (independent of the insertion point, 119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and invisible in the GUI) across calls to 120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>transliterate()</code>. Typically, the cursor will 121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * be coincident with the insertion point, but in a case like the one 122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * above, it will precede the insertion point. 123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Keyboard transliteration methods maintain a set of three indices 125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * that are updated with each call to 126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>transliterate()</code>, including the cursor, start, 127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and limit. Since these indices are changed by the method, they are 128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * passed in an <code>int[]</code> array. The <code>START</code> index 129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * marks the beginning of the substring that the transliterator will 130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * look at. It is advanced as text becomes committed (but it is not 131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the committed index; that's the <code>CURSOR</code>). The 132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>CURSOR</code> index, described above, marks the point at 133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * which the transliterator last stopped, either because it reached 134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the end, or because it required more characters to disambiguate 135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * between possible inputs. The <code>CURSOR</code> can also be 136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * explicitly set by rules in a <code>RuleBasedTransliterator</code>. 137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Any characters before the <code>CURSOR</code> index are frozen; 138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * future keyboard transliteration calls within this input sequence 139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * will not change them. New text is inserted at the 140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>LIMIT</code> index, which marks the end of the substring that 141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the transliterator looks at. 142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Because keyboard transliteration assumes that more characters 144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * are to arrive, it is conservative in its operation. It only 145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterates when it can do so unambiguously. Otherwise it waits 146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * for more characters to arrive. When the client code knows that no 147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * more characters are forthcoming, perhaps because the user has 148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * performed some input termination operation, then it should call 149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>finishTransliteration()</code> to complete any 150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pending transliterations. 151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><b>Inverses</b> 153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Pairs of transliterators may be inverses of one another. For 155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * example, if transliterator <b>A</b> transliterates characters by 156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * incrementing their Unicode value (so "abc" -> "def"), and 157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator <b>B</b> decrements character values, then <b>A</b> 158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is an inverse of <b>B</b> and vice versa. If we compose <b>A</b> 159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * with <b>B</b> in a compound transliterator, the result is the 160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * indentity transliterator, that is, a transliterator that does not 161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * change its input text. 162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The <code>Transliterator</code> method <code>getInverse()</code> 164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * returns a transliterator's inverse, if one exists, or 165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>null</code> otherwise. However, the result of 166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>getInverse()</code> usually will <em>not</em> be a true 167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * mathematical inverse. This is because true inverse transliterators 168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * are difficult to formulate. For example, consider two 169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterators: <b>AB</b>, which transliterates the character 'A' 170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to 'B', and <b>BA</b>, which transliterates 'B' to 'A'. It might 171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * seem that these are exact inverses, since 172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \htmlonly<blockquote>\endhtmlonly"A" x <b>AB</b> -> "B"<br> 174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * "B" x <b>BA</b> -> "A"\htmlonly</blockquote>\endhtmlonly 175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * where 'x' represents transliteration. However, 177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \htmlonly<blockquote>\endhtmlonly"ABCD" x <b>AB</b> -> "BBCD"<br> 179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * "BBCD" x <b>BA</b> -> "AACD"\htmlonly</blockquote>\endhtmlonly 180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * so <b>AB</b> composed with <b>BA</b> is not the 182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * identity. Nonetheless, <b>BA</b> may be usefully considered to be 183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <b>AB</b>'s inverse, and it is on this basis that 184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <b>AB</b><code>.getInverse()</code> could legitimately return 185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <b>BA</b>. 186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><b>IDs and display names</b> 188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>A transliterator is designated by a short identifier string or 190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>ID</em>. IDs follow the format <em>source-destination</em>, 191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * where <em>source</em> describes the entity being replaced, and 192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>destination</em> describes the entity replacing 193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>source</em>. The entities may be the names of scripts, 194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * particular sequences of characters, or whatever else it is that the 195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator converts to or from. For example, a transliterator 196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * from Russian to Latin might be named "Russian-Latin". A 197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator from keyboard escape sequences to Latin-1 characters 198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * might be named "KeyboardEscape-Latin1". By convention, system 199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * entity names are in English, with the initial letters of words 200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * capitalized; user entity names may follow any format so long as 201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * they do not contain dashes. 202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>In addition to programmatic IDs, transliterator objects have 204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * display names for presentation in user interfaces, returned by 205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * {@link #getDisplayName }. 206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><b>Factory methods and registration</b> 208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>In general, client code should use the factory method 210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * {@link #createInstance } to obtain an instance of a 211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator given its ID. Valid IDs may be enumerated using 212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>getAvailableIDs()</code>. Since transliterators are mutable, 213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * multiple calls to {@link #createInstance } with the same ID will 214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * return distinct objects. 215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>In addition to the system transliterators registered at startup, 217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * user transliterators may be registered by calling 218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>registerInstance()</code> at run time. A registered instance 219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * acts a template; future calls to {@link #createInstance } with the ID 220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of the registered object return clones of that object. Thus any 221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * object passed to <tt>registerInstance()</tt> must implement 222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tt>clone()</tt> propertly. To register a transliterator subclass 223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * without instantiating it (until it is needed), users may call 224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * {@link #registerFactory }. In this case, the objects are 225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * instantiated by invoking the zero-argument public constructor of 226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the class. 227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><b>Subclassing</b> 229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Subclasses must implement the abstract method 231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>handleTransliterate()</code>. <p>Subclasses should override 232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the <code>transliterate()</code> method taking a 233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>Replaceable</code> and the <code>transliterate()</code> 234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * method taking a <code>String</code> and <code>StringBuffer</code> 235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * if the performance of these methods can be improved over the 236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * performance obtained by the default implementations in this class. 237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @author Alan Liu 239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass U_I18N_API Transliterator : public UObject { 242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Programmatic name, e.g., "Latin-Arabic". 247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString ID; 249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This transliterator's filter. Any character for which 252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tt>filter.contains()</tt> returns <tt>false</tt> will not be 253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * altered by this transliterator. If <tt>filter</tt> is 254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tt>null</tt> then no filtering is applied. 255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeFilter* filter; 257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t maximumContextLength; 259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru public: 261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * A context integer or pointer for a factory function, passed by 264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * value. 265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru union Token { 268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This token, interpreted as a 32-bit integer. 270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t integer; 273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This token, interpreted as a native pointer. 275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void* pointer; 278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru }; 279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 280103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API 281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return a token containing an integer. 283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a token containing an integer. 284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru inline static Token integerToken(int32_t); 287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return a token containing a pointer. 290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a token containing a pointer. 291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru inline static Token pointerToken(void*); 294103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif /* U_HIDE_INTERNAL_API */ 295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * A function that creates and returns a Transliterator. When 298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * invoked, it will be passed the ID string that is being 299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * instantiated, together with the context pointer that was passed 300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * in when the factory function was first registered. Many 301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * factory functions will ignore both parameters, however, 302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * functions that are registered to more than one ID may use the 303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * ID or the context parameter to parameterize the transliterator 304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * they create. 305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param ID the string identifier for this transliterator 306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param context a context pointer that will be stored and 307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * later passed to the factory function when an ID matching 308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the registration ID is being instantiated with this factory. 309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru typedef Transliterator* (U_EXPORT2 *Factory)(const UnicodeString& ID, Token context); 312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected: 314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Default constructor. 317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param ID the string identifier for this transliterator 318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param adoptedFilter the filter. Any character for which 319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tt>filter.contains()</tt> returns <tt>false</tt> will not be 320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * altered by this transliterator. If <tt>filter</tt> is 321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tt>null</tt> then no filtering is applied. 322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Transliterator(const UnicodeString& ID, UnicodeFilter* adoptedFilter); 325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Copy constructor. 328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Transliterator(const Transliterator&); 331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Assignment operator. 334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Transliterator& operator=(const Transliterator&); 337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Create a transliterator from a basic ID. This is an ID 340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * containing only the forward direction source, target, and 341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * variant. 342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param id a basic ID of the form S-T or S-T/V. 343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param canon canonical ID to assign to the object, or 344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * NULL to leave the ID unchanged 345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a newly created Transliterator or null if the ID is 346ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * invalid. 347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static Transliterator* createBasicInstance(const UnicodeString& id, 350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString* canon); 351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru friend class TransliteratorParser; // for parseID() 353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru friend class TransliteratorIDParser; // for createBasicInstance() 354ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru friend class TransliteratorAlias; // for setID() 355ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Destructor. 360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 361ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual ~Transliterator(); 363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 365ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Implements Cloneable. 366ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * All subclasses are encouraged to implement this method if it is 367ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * possible and reasonable to do so. Subclasses that are to be 368ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * registered with the system using <tt>registerInstance()</tt> 369ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * are required to implement this method. If a subclass does not 370ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * implement clone() properly and is registered with the system 371ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * using registerInstance(), then the default clone() implementation 372ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * will return null, and calls to createInstance() will fail. 373ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 374ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a copy of the object. 375ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #registerInstance 376ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 377ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 378ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual Transliterator* clone() const; 379ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 380ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 381ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Transliterates a segment of a string, with optional filtering. 382ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 383ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param text the string to be transliterated 384ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param start the beginning index, inclusive; <code>0 <= start 385ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <= limit</code>. 386ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param limit the ending index, exclusive; <code>start <= limit 387ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <= text.length()</code>. 388ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return The new limit index. The text previously occupying <code>[start, 389ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * limit)</code> has been transliterated, possibly to a string of a different 390ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * length, at <code>[start, </code><em>new-limit</em><code>)</code>, where 391ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <em>new-limit</em> is the return value. If the input offsets are out of bounds, 392ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the returned value is -1 and the input string remains unchanged. 393ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 394ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 395ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual int32_t transliterate(Replaceable& text, 396ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t start, int32_t limit) const; 397ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 398ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 399ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Transliterates an entire string in place. Convenience method. 400ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param text the string to be transliterated 401ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 402ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 403ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void transliterate(Replaceable& text) const; 404ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 405ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 406ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Transliterates the portion of the text buffer that can be 407ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterated unambiguosly after new text has been inserted, 408ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * typically as a result of a keyboard event. The new text in 409ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>insertion</code> will be inserted into <code>text</code> 410ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * at <code>index.limit</code>, advancing 411ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>index.limit</code> by <code>insertion.length()</code>. 412ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Then the transliterator will try to transliterate characters of 413ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>text</code> between <code>index.cursor</code> and 414ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>index.limit</code>. Characters before 415ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>index.cursor</code> will not be changed. 416ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 417ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Upon return, values in <code>index</code> will be updated. 418ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>index.start</code> will be advanced to the first 419ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * character that future calls to this method will read. 420ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>index.cursor</code> and <code>index.limit</code> will 421ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * be adjusted to delimit the range of text that future calls to 422ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * this method may change. 423ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 424ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Typical usage of this method begins with an initial call 425ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * with <code>index.start</code> and <code>index.limit</code> 426ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * set to indicate the portion of <code>text</code> to be 427ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterated, and <code>index.cursor == index.start</code>. 428ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Thereafter, <code>index</code> can be used without 429ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * modification in future calls, provided that all changes to 430ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>text</code> are made via this method. 431ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 432ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>This method assumes that future calls may be made that will 433ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * insert new text into the buffer. As a result, it only performs 434ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * unambiguous transliterations. After the last call to this 435ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * method, there may be untransliterated text that is waiting for 436ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * more input to resolve an ambiguity. In order to perform these 437ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pending transliterations, clients should call {@link 438ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * #finishTransliteration } after the last call to this 439ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * method has been made. 440ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 441ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param text the buffer holding transliterated and untransliterated text 442ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param index an array of three integers. 443ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 444ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <ul><li><code>index.start</code>: the beginning index, 445ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * inclusive; <code>0 <= index.start <= index.limit</code>. 446ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 447ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li><code>index.limit</code>: the ending index, exclusive; 448ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>index.start <= index.limit <= text.length()</code>. 449ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>insertion</code> is inserted at 450ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>index.limit</code>. 451ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 452ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li><code>index.cursor</code>: the next character to be 453ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * considered for transliteration; <code>index.start <= 454ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * index.cursor <= index.limit</code>. Characters before 455ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>index.cursor</code> will not be changed by future calls 456ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to this method.</ul> 457ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 458ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param insertion text to be inserted and possibly 459ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterated into the translation buffer at 460ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>index.limit</code>. If <code>null</code> then no text 461ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is inserted. 462ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param to filled in with a success or an error. 463ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #handleTransliterate 464ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @exception IllegalArgumentException if <code>index</code> 465ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is invalid 466ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see UTransPosition 467ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 468ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 469ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void transliterate(Replaceable& text, UTransPosition& index, 470ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& insertion, 471ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status) const; 472ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 473ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 474ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Transliterates the portion of the text buffer that can be 475ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterated unambiguosly after a new character has been 476ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * inserted, typically as a result of a keyboard event. This is a 47785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * convenience method. 478ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param text the buffer holding transliterated and 479ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * untransliterated text 48085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * @param index an array of three integers. 481ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param insertion text to be inserted and possibly 482ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterated into the translation buffer at 483ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>index.limit</code>. 484ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param to filled in with a success or an error. 485ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode&) const 486ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 487ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 488ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void transliterate(Replaceable& text, UTransPosition& index, 489ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar32 insertion, 490ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status) const; 491ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 492ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 493ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Transliterates the portion of the text buffer that can be 494ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterated unambiguosly. This is a convenience method; see 495ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * {@link 496ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode&) const } 497ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * for details. 498ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param text the buffer holding transliterated and 499ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * untransliterated text 50054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @param index an array of three integers. See {@link #transliterate(Replaceable&, UTransPosition&, const UnicodeString*, UErrorCode&) const }. 501ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param to filled in with a success or an error. 502ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #transliterate(Replaceable, int[], String) 503ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 504ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 505ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void transliterate(Replaceable& text, UTransPosition& index, 506ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status) const; 507ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 508ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 509ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Finishes any pending transliterations that were waiting for 510ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * more characters. Clients should call this method as the last 511ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * call after a sequence of one or more calls to 512ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>transliterate()</code>. 513ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param text the buffer holding transliterated and 514ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * untransliterated text. 515ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param index the array of indices previously passed to {@link 516ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * #transliterate } 517ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 518ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 519ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void finishTransliteration(Replaceable& text, 520ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UTransPosition& index) const; 521ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 522ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 523ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 524ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 525ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This internal method does incremental transliteration. If the 526ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 'insertion' is non-null then we append it to 'text' before 527ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * proceeding. This method calls through to the pure virtual 528ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * framework method handleTransliterate() to do the actual 529ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * work. 530ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param text the buffer holding transliterated and 531ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * untransliterated text 532ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param index an array of three integers. See {@link 533ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * #transliterate(Replaceable, int[], String)}. 534ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param insertion text to be inserted and possibly 535ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterated into the translation buffer at 536ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>index.limit</code>. 537ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param to filled in with a success or an error. 538ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 539ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void _transliterate(Replaceable& text, 540ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UTransPosition& index, 541ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString* insertion, 542ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode &status) const; 543ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 544ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected: 545ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 546ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 547ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Abstract method that concrete subclasses define to implement 548ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * their transliteration algorithm. This method handles both 549ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * incremental and non-incremental transliteration. Let 550ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>originalStart</code> refer to the value of 551ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>pos.start</code> upon entry. 552ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 553ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <ul> 554ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>If <code>incremental</code> is false, then this method 555ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * should transliterate all characters between 556ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>pos.start</code> and <code>pos.limit</code>. Upon return 557ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>pos.start</code> must == <code> pos.limit</code>.</li> 558ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 559ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>If <code>incremental</code> is true, then this method 560ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * should transliterate all characters between 561ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>pos.start</code> and <code>pos.limit</code> that can be 562ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * unambiguously transliterated, regardless of future insertions 563ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of text at <code>pos.limit</code>. Upon return, 564ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>pos.start</code> should be in the range 565ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * [<code>originalStart</code>, <code>pos.limit</code>). 566ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>pos.start</code> should be positioned such that 567ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * characters [<code>originalStart</code>, <code> 568ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pos.start</code>) will not be changed in the future by this 569ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator and characters [<code>pos.start</code>, 570ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>pos.limit</code>) are unchanged.</li> 571ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </ul> 572ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 573ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Implementations of this method should also obey the 574ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * following invariants:</p> 575ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 576ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <ul> 577ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li> <code>pos.limit</code> and <code>pos.contextLimit</code> 578ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * should be updated to reflect changes in length of the text 579ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * between <code>pos.start</code> and <code>pos.limit</code>. The 580ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * difference <code> pos.contextLimit - pos.limit</code> should 581ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * not change.</li> 582ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 583ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li><code>pos.contextStart</code> should not change.</li> 584ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 585ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Upon return, neither <code>pos.start</code> nor 586ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>pos.limit</code> should be less than 587ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>originalStart</code>.</li> 588ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 589ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Text before <code>originalStart</code> and text after 590ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>pos.limit</code> should not change.</li> 591ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 592ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <li>Text before <code>pos.contextStart</code> and text after 593ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code> pos.contextLimit</code> should be ignored.</li> 594ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * </ul> 595ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 596ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Subclasses may safely assume that all characters in 597ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * [<code>pos.start</code>, <code>pos.limit</code>) are filtered. 598ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * In other words, the filter has already been applied by the time 599ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * this method is called. See 600ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>filteredTransliterate()</code>. 601ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 602ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>This method is <b>not</b> for public consumption. Calling 603ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * this method directly will transliterate 604ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * [<code>pos.start</code>, <code>pos.limit</code>) without 605ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * applying the filter. End user code should call <code> 606ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterate()</code> instead of this method. Subclass code 607ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and wrapping transliterators should call 608ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>filteredTransliterate()</code> instead of this method.<p> 609ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 610ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param text the buffer holding transliterated and 611ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * untransliterated text 612ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 613ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param pos the indices indicating the start, limit, context 614ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * start, and context limit of the text. 615ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 616ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param incremental if true, assume more text may be inserted at 617ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>pos.limit</code> and act accordingly. Otherwise, 618ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterate all text between <code>pos.start</code> and 619ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>pos.limit</code> and move <code>pos.start</code> up to 620ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>pos.limit</code>. 621ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 622ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #transliterate 623ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 624ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 625ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void handleTransliterate(Replaceable& text, 626ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UTransPosition& pos, 627ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool incremental) const = 0; 628ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 629ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 630ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 631ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Transliterate a substring of text, as specified by index, taking filters 632ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * into account. This method is for subclasses that need to delegate to 633ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * another transliterator, such as CompoundTransliterator. 634ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param text the text to be transliterated 635ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param index the position indices 636ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param incremental if TRUE, then assume more characters may be inserted 637ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * at index.limit, and postpone processing to accomodate future incoming 638ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * characters 639ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 640ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 641ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void filteredTransliterate(Replaceable& text, 642ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UTransPosition& index, 643ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool incremental) const; 644ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 645ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 646ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 647ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 648ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Top-level transliteration method, handling filtering, incremental and 649ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * non-incremental transliteration, and rollback. All transliteration 650ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * public API methods eventually call this method with a rollback argument 651ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of TRUE. Other entities may call this method but rollback should be 652ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * FALSE. 653ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 654ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>If this transliterator has a filter, break up the input text into runs 655ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of unfiltered characters. Pass each run to 656b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho * subclass.handleTransliterate(). 657ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 658ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>In incremental mode, if rollback is TRUE, perform a special 659ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * incremental procedure in which several passes are made over the input 660ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * text, adding one character at a time, and committing successful 661ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterations as they occur. Unsuccessful transliterations are rolled 662ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * back and retried with additional characters to give correct results. 663ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 664ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param text the text to be transliterated 665ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param index the position indices 666ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param incremental if TRUE, then assume more characters may be inserted 667ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * at index.limit, and postpone processing to accomodate future incoming 668ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * characters 669ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param rollback if TRUE and if incremental is TRUE, then perform special 670ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * incremental processing, as described above, and undo partial 671ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterations where necessary. If incremental is FALSE then this 672ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * parameter is ignored. 673ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 674ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void filteredTransliterate(Replaceable& text, 675ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UTransPosition& index, 676ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool incremental, 677ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool rollback) const; 678ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 679ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 680ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 681ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 682ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the length of the longest context required by this transliterator. 683ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This is <em>preceding</em> context. The default implementation supplied 684ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * by <code>Transliterator</code> returns zero; subclasses 685ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * that use preceding context should override this method to return the 686ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * correct value. For example, if a transliterator translates "ddd" (where 687ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * d is any digit) to "555" when preceded by "(ddd)", then the preceding 688ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * context length is 5, the length of "(ddd)". 689ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 690ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return The maximum number of preceding context characters this 691ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator needs to examine 692ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 693ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 694ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t getMaximumContextLength(void) const; 695ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 696ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected: 697ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 698ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 699ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Method for subclasses to use to set the maximum context length. 700ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param maxContextLength the new value to be set. 701ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getMaximumContextLength 702ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 703ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 704ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void setMaximumContextLength(int32_t maxContextLength); 705ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 706ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 707ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 708ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 709ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns a programmatic identifier for this transliterator. 710ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * If this identifier is passed to <code>createInstance()</code>, it 711ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * will return this object, if it has been registered. 712ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a programmatic identifier for this transliterator. 713ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #registerInstance 714ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #registerFactory 715ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getAvailableIDs 716ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 717ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 718ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual const UnicodeString& getID(void) const; 719ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 720ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 721ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns a name for this transliterator that is appropriate for 722ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * display to the user in the default locale. See {@link 723ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * #getDisplayName } for details. 724ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param ID the string identifier for this transliterator 725ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result Output param to receive the display name 726ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A reference to 'result'. 727ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 728ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 729ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static UnicodeString& U_EXPORT2 getDisplayName(const UnicodeString& ID, 730ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& result); 731ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 732ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 733ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns a name for this transliterator that is appropriate for 734ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * display to the user in the given locale. This name is taken 735ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * from the locale resource data in the standard manner of the 736ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>java.text</code> package. 737ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 738ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>If no localized names exist in the system resource bundles, 739ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a name is synthesized using a localized 740ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>MessageFormat</code> pattern from the resource data. The 741ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * arguments to this pattern are an integer followed by one or two 742ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * strings. The integer is the number of strings, either 1 or 2. 743ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The strings are formed by splitting the ID for this 744ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator at the first '-'. If there is no '-', then the 745ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * entire ID forms the only string. 746ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param ID the string identifier for this transliterator 747ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param inLocale the Locale in which the display name should be 748ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * localized. 749ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result Output param to receive the display name 750ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A reference to 'result'. 751ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 752ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 753ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static UnicodeString& U_EXPORT2 getDisplayName(const UnicodeString& ID, 754ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const Locale& inLocale, 755ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& result); 756ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 757ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 758ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the filter used by this transliterator, or <tt>NULL</tt> 759ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * if this transliterator uses no filter. 760ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the filter used by this transliterator, or <tt>NULL</tt> 761ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * if this transliterator uses no filter. 762ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 763ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 764ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeFilter* getFilter(void) const; 765ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 766ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 767ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the filter used by this transliterator, or <tt>NULL</tt> if this 768ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator uses no filter. The caller must eventually delete the 769ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * result. After this call, this transliterator's filter is set to 770ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tt>NULL</tt>. 771ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the filter used by this transliterator, or <tt>NULL</tt> if this 772ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator uses no filter. 773ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 774ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 775ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeFilter* orphanFilter(void); 776ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 777ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 778ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Changes the filter used by this transliterator. If the filter 779ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is set to <tt>null</tt> then no filtering will occur. 780ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 781ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Callers must take care if a transliterator is in use by 782ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * multiple threads. The filter should not be changed by one 783ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * thread while another thread may be transliterating. 784ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param adoptedFilter the new filter to be adopted. 785ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 786ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 787ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void adoptFilter(UnicodeFilter* adoptedFilter); 788ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 789ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 790ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns this transliterator's inverse. See the class 791ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * documentation for details. This implementation simply inverts 792ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the two entities in the ID and attempts to retrieve the 793ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * resulting transliterator. That is, if <code>getID()</code> 794ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * returns "A-B", then this method will return the result of 795ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>createInstance("B-A")</code>, or <code>null</code> if that 796ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * call fails. 797ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 798ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Subclasses with knowledge of their inverse may wish to 799ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * override this method. 800ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 801ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param to filled in with a success or an error. 802ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a transliterator that is an inverse, not necessarily 803ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * exact, of this transliterator, or <code>null</code> if no such 804ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator is registered. 805ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #registerInstance 806ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 807ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 808ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Transliterator* createInverse(UErrorCode& status) const; 809ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 810ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 811ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns a <code>Transliterator</code> object given its ID. 812ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The ID must be either a system transliterator ID or a ID registered 813ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * using <code>registerInstance()</code>. 814ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 815ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param ID a valid ID, as enumerated by <code>getAvailableIDs()</code> 816ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param dir either FORWARD or REVERSE. 817ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param parseError Struct to recieve information on position 818ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of error if an error is encountered 819ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param to filled in with a success or an error. 820ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A <code>Transliterator</code> object with the given ID 821ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #registerInstance 822ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getAvailableIDs 823ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getID 824ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 825ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 826ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static Transliterator* U_EXPORT2 createInstance(const UnicodeString& ID, 827ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UTransDirection dir, 828ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UParseError& parseError, 829ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status); 830ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 831ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 832ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns a <code>Transliterator</code> object given its ID. 833ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The ID must be either a system transliterator ID or a ID registered 834ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * using <code>registerInstance()</code>. 835ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param ID a valid ID, as enumerated by <code>getAvailableIDs()</code> 836ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param dir either FORWARD or REVERSE. 837ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param to filled in with a success or an error. 838ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A <code>Transliterator</code> object with the given ID 839ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 840ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 841ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static Transliterator* U_EXPORT2 createInstance(const UnicodeString& ID, 842ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UTransDirection dir, 843ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status); 844ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 845ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 846ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns a <code>Transliterator</code> object constructed from 847ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the given rule string. This will be a RuleBasedTransliterator, 848ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * if the rule string contains only rules, or a 849ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * CompoundTransliterator, if it contains ID blocks, or a 850ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * NullTransliterator, if it contains ID blocks which parse as 851ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * empty for the given direction. 852ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param ID the id for the transliterator. 853ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param rules rules, separated by ';' 854ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param dir either FORWARD or REVERSE. 855ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param parseError Struct to recieve information on position 856ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of error if an error is encountered 857ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status Output param set to success/failure code. 858ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 859ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 860ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static Transliterator* U_EXPORT2 createFromRules(const UnicodeString& ID, 861ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& rules, 862ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UTransDirection dir, 863ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UParseError& parseError, 864ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode& status); 865ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 866ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 867ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Create a rule string that can be passed to createFromRules() 868ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to recreate this transliterator. 869ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result the string to receive the rules. Previous 870ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * contents will be deleted. 871ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param escapeUnprintable if TRUE then convert unprintable 872ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * character to their hex escape representations, \\uxxxx or 873ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \\Uxxxxxxxx. Unprintable characters are those other than 874ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * U+000A, U+0020..U+007E. 875ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 876ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 877ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UnicodeString& toRules(UnicodeString& result, 878ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool escapeUnprintable) const; 879ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 880ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 881ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the number of elements that make up this transliterator. 882ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For example, if the transliterator "NFD;Jamo-Latin;Latin-Greek" 883ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * were created, the return value of this method would be 3. 884ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 885ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>If this transliterator is not composed of other 886ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterators, then this method returns 1. 887ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the number of transliterators that compose this 888ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator, or 1 if this transliterator is not composed of 889ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * multiple transliterators 890ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.0 891ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 892ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t countElements() const; 893ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 894ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 895ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return an element that makes up this transliterator. For 896ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * example, if the transliterator "NFD;Jamo-Latin;Latin-Greek" 897ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * were created, the return value of this method would be one 898ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of the three transliterator objects that make up that 899ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator: [NFD, Jamo-Latin, Latin-Greek]. 900ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 901ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>If this transliterator is not composed of other 902ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterators, then this method will return a reference to 903ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * this transliterator when given the index 0. 904ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param index a value from 0..countElements()-1 indicating the 905ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator to return 906ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param ec input-output error code 907ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return one of the transliterators that makes up this 908ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterator, if this transliterator is made up of multiple 909ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * transliterators, otherwise a reference to this object if given 910ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * an index of 0 911ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.0 912ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 913ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const Transliterator& getElement(int32_t index, UErrorCode& ec) const; 914ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 915ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 916ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the set of all characters that may be modified in the 917ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * input text by this Transliterator. This incorporates this 918ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * object's current filter; if the filter is changed, the return 919ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * value of this function will change. The default implementation 920ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * returns an empty set. Some subclasses may override {@link 921ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * #handleGetSourceSet } to return a more precise result. The 922ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * return result is approximate in any case and is intended for 923ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * use by tests, tools, or utilities. 924ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result receives result set; previous contents lost 925ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a reference to result 926ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getTargetSet 927ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #handleGetSourceSet 928ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 929ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 930ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeSet& getSourceSet(UnicodeSet& result) const; 931ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 932ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 933ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Framework method that returns the set of all characters that 934ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * may be modified in the input text by this Transliterator, 935ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * ignoring the effect of this object's filter. The base class 936ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * implementation returns the empty set. Subclasses that wish to 937ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * implement this should override this method. 938ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the set of characters that this transliterator may 939ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * modify. The set may be modified, so subclasses should return a 940ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * newly-created object. 941ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result receives result set; previous contents lost 942ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getSourceSet 943ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getTargetSet 944ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 945ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 946ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void handleGetSourceSet(UnicodeSet& result) const; 947ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 948ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 949ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns the set of all characters that may be generated as 950ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * replacement text by this transliterator. The default 951ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * implementation returns the empty set. Some subclasses may 952ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * override this method to return a more precise result. The 953ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * return result is approximate in any case and is intended for 954ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * use by tests, tools, or utilities requiring such 955ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * meta-information. 956ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result receives result set; previous contents lost 957ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a reference to result 958ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #getTargetSet 959ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 960ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 961ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UnicodeSet& getTargetSet(UnicodeSet& result) const; 962ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 963ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 964ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 965ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 966ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Registers a factory function that creates transliterators of 967ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a given ID. 968fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * 969fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Because ICU may choose to cache Transliterators internally, this must 970fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * be called at application startup, prior to any calls to 971fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Transliterator::createXXX to avoid undefined behavior. 972fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * 973ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param id the ID being registered 974ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param factory a function pointer that will be copied and 975ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * called later when the given ID is passed to createInstance() 976ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param context a context pointer that will be stored and 977ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * later passed to the factory function when an ID matching 978ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the registration ID is being instantiated with this factory. 979ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 980ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 981ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static void U_EXPORT2 registerFactory(const UnicodeString& id, 982ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Factory factory, 983ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Token context); 984ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 985ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 986ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Registers an instance <tt>obj</tt> of a subclass of 987ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>Transliterator</code> with the system. When 988ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <tt>createInstance()</tt> is called with an ID string that is 989ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * equal to <tt>obj->getID()</tt>, then <tt>obj->clone()</tt> is 990ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * returned. 991ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 992ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * After this call the Transliterator class owns the adoptedObj 993ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and will delete it. 994ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 995fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Because ICU may choose to cache Transliterators internally, this must 996fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * be called at application startup, prior to any calls to 997fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Transliterator::createXXX to avoid undefined behavior. 998fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * 999ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param adoptedObj an instance of subclass of 1000ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>Transliterator</code> that defines <tt>clone()</tt> 1001ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #createInstance 1002ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #registerFactory 1003ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #unregister 1004ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1005ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1006ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static void U_EXPORT2 registerInstance(Transliterator* adoptedObj); 1007ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1008ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1009ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Registers an ID string as an alias of another ID string. 1010ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * That is, after calling this function, <tt>createInstance(aliasID)</tt> 1011ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * will return the same thing as <tt>createInstance(realID)</tt>. 1012ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This is generally used to create shorter, more mnemonic aliases 1013ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * for long compound IDs. 1014ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1015ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param aliasID The new ID being registered. 1016ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param realID The ID that the new ID is to be an alias for. 1017ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This can be a compound ID and can include filters and should 1018ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * refer to transliterators that have already been registered with 1019ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the framework, although this isn't checked. 1020ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.6 1021ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1022ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static void U_EXPORT2 registerAlias(const UnicodeString& aliasID, 1023ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& realID); 1024ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1025ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected: 1026ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1027103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API 1028ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1029ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 1030ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param id the ID being registered 1031ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param factory a function pointer that will be copied and 1032ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * called later when the given ID is passed to createInstance() 1033ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param context a context pointer that will be stored and 1034ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * later passed to the factory function when an ID matching 1035ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the registration ID is being instantiated with this factory. 1036ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1037ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static void _registerFactory(const UnicodeString& id, 1038ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Factory factory, 1039ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Token context); 1040ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1041ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1042ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 1043ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1044ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static void _registerInstance(Transliterator* adoptedObj); 1045ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1046ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1047ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 1048ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1049ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static void _registerAlias(const UnicodeString& aliasID, const UnicodeString& realID); 1050ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1051ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1052ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Register two targets as being inverses of one another. For 1053ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * example, calling registerSpecialInverse("NFC", "NFD", true) causes 1054ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Transliterator to form the following inverse relationships: 1055ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1056ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <pre>NFC => NFD 1057ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Any-NFC => Any-NFD 1058ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * NFD => NFC 1059ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Any-NFD => Any-NFC</pre> 1060ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1061ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (Without the special inverse registration, the inverse of NFC 1062ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * would be NFC-Any.) Note that NFD is shorthand for Any-NFD, but 1063ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * that the presence or absence of "Any-" is preserved. 1064ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1065ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The relationship is symmetrical; registering (a, b) is 1066ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * equivalent to registering (b, a). 1067ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1068ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The relevant IDs must still be registered separately as 1069ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * factories or classes. 1070ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1071ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Only the targets are specified. Special inverses always 1072ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * have the form Any-Target1 <=> Any-Target2. The target should 1073ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * have canonical casing (the casing desired to be produced when 1074ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * an inverse is formed) and should contain no whitespace or other 1075ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * extraneous characters. 1076ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1077ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param target the target against which to register the inverse 1078ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param inverseTarget the inverse of target, that is 1079ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Any-target.getInverse() => Any-inverseTarget 1080ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param bidirectional if true, register the reverse relation 1081ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * as well, that is, Any-inverseTarget.getInverse() => Any-target 1082ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 1083ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1084ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static void _registerSpecialInverse(const UnicodeString& target, 1085ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& inverseTarget, 1086ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool bidirectional); 1087103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif /* U_HIDE_INTERNAL_API */ 1088ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1089ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 1090ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1091ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1092ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Unregisters a transliterator or class. This may be either 1093ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a system transliterator or a user transliterator or class. 1094ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Any attempt to construct an unregistered transliterator based 1095ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * on its ID will fail. 1096ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1097fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Because ICU may choose to cache Transliterators internally, this should 1098fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * be called during application shutdown, after all calls to 1099fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * Transliterator::createXXX to avoid undefined behavior. 1100fceb39872958b9fa2505e63f8b8699a9e0f882f4ccornelius * 1101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param ID the ID of the transliterator or class 1102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the <code>Object</code> that was registered with 1103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <code>ID</code>, or <code>null</code> if none was 1104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #registerInstance 1105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see #registerFactory 1106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static void U_EXPORT2 unregister(const UnicodeString& ID); 1109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 1111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return a StringEnumeration over the IDs available at the time of the 1114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * call, including user-registered IDs. 1115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param ec input-output error code 1116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a newly-created StringEnumeration over the transliterators 1117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * available at the time of the call. The caller should delete this object 1118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * when done using it. 1119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.0 1120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static StringEnumeration* U_EXPORT2 getAvailableIDs(UErrorCode& ec); 1122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the number of registered source specifiers. 1125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the number of registered source specifiers. 1126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static int32_t U_EXPORT2 countAvailableSources(void); 1129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return a registered source specifier. 1132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param index which specifier to return, from 0 to n-1, where 1133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * n = countAvailableSources() 1134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result fill-in paramter to receive the source specifier. 1135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * If index is out of range, result will be empty. 1136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return reference to result 1137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static UnicodeString& U_EXPORT2 getAvailableSource(int32_t index, 1140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& result); 1141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the number of registered target specifiers for a given 1144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * source specifier. 1145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param source the given source specifier. 1146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the number of registered target specifiers for a given 1147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * source specifier. 1148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static int32_t U_EXPORT2 countAvailableTargets(const UnicodeString& source); 1151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return a registered target specifier for a given source. 1154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param index which specifier to return, from 0 to n-1, where 1155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * n = countAvailableTargets(source) 1156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param source the source specifier 1157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result fill-in paramter to receive the target specifier. 1158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * If source is invalid or if index is out of range, result will 1159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * be empty. 1160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return reference to result 1161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static UnicodeString& U_EXPORT2 getAvailableTarget(int32_t index, 1164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& source, 1165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& result); 1166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the number of registered variant specifiers for a given 1169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * source-target pair. 1170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param source the source specifiers. 1171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param target the target specifiers. 1172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static int32_t U_EXPORT2 countAvailableVariants(const UnicodeString& source, 1175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& target); 1176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return a registered variant specifier for a given source-target 1179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pair. 1180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param index which specifier to return, from 0 to n-1, where 1181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * n = countAvailableVariants(source, target) 1182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param source the source specifier 1183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param target the target specifier 1184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param result fill-in paramter to receive the variant 1185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * specifier. If source is invalid or if target is invalid or if 1186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * index is out of range, result will be empty. 1187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return reference to result 1188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static UnicodeString& U_EXPORT2 getAvailableVariant(int32_t index, 1191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& source, 1192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& target, 1193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& result); 1194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected: 1196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1197103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API 1198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Non-mutexed internal method 1200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 1201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static int32_t _countAvailableSources(void); 1203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Non-mutexed internal method 1206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 1207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static UnicodeString& _getAvailableSource(int32_t index, 1209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& result); 1210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Non-mutexed internal method 1213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 1214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static int32_t _countAvailableTargets(const UnicodeString& source); 1216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Non-mutexed internal method 1219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 1220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static UnicodeString& _getAvailableTarget(int32_t index, 1222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& source, 1223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& result); 1224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Non-mutexed internal method 1227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 1228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static int32_t _countAvailableVariants(const UnicodeString& source, 1230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& target); 1231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Non-mutexed internal method 1234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 1235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static UnicodeString& _getAvailableVariant(int32_t index, 1237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& source, 1238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UnicodeString& target, 1239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString& result); 1240103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif /* U_HIDE_INTERNAL_API */ 1241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected: 1243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Set the ID of this transliterators. Subclasses shouldn't do 1246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * this, unless the underlying script behavior has changed. 1247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param id the new id t to be set. 1248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 1249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void setID(const UnicodeString& id); 1251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 1253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the class ID for this class. This is useful only for 1256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * comparing to a return value from getDynamicClassID(). 1257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Note that Transliterator is an abstract base class, and therefor 1258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * no fully constructed object will have a dynamic 1259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * UCLassID that equals the UClassID returned from 1260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * TRansliterator::getStaticClassID(). 1261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return The class ID for class Transliterator. 1262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static UClassID U_EXPORT2 getStaticClassID(void); 1265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Returns a unique class ID <b>polymorphically</b>. This method 1268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is to implement a simple version of RTTI, since not all C++ 1269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * compilers support genuine RTTI. Polymorphic operator==() and 1270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * clone() methods call this method. 1271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Concrete subclasses of Transliterator must use the 1273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * UOBJECT_DEFINE_RTTI_IMPLEMENTATION macro from 1274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * uobject.h to provide the RTTI functions. 1275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return The class ID for this object. All objects of a given 1277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * class have the same class ID. Objects of other classes have 1278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * different class IDs. 1279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.0 1280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UClassID getDynamicClassID(void) const = 0; 1282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 128485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho static UBool initializeRegistry(UErrorCode &status); 1285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 1287103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_OBSOLETE_API 1288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the number of IDs currently registered with the system. 1290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * To retrieve the actual IDs, call getAvailableID(i) with 1291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * i from 0 to countAvailableIDs() - 1. 1292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the number of IDs currently registered with the system. 1293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @obsolete ICU 3.4 use getAvailableIDs() instead 1294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static int32_t U_EXPORT2 countAvailableIDs(void); 1296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 1298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Return the index-th available ID. index must be between 0 1299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and countAvailableIDs() - 1, inclusive. If index is out of 1300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * range, the result of getAvailableID(0) is returned. 1301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param index the given ID index. 1302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return the index-th available ID. index must be between 0 1303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and countAvailableIDs() - 1, inclusive. If index is out of 1304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * range, the result of getAvailableID(0) is returned. 1305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @obsolete ICU 3.4 use getAvailableIDs() instead; this function 1306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is not thread safe, since it returns a reference to storage that 1307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * may become invalid if another thread calls unregister 1308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 1309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static const UnicodeString& U_EXPORT2 getAvailableID(int32_t index); 1310103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif /* U_HIDE_OBSOLETE_API */ 1311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 1312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline int32_t Transliterator::getMaximumContextLength(void) const { 1314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return maximumContextLength; 1315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 1316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline void Transliterator::setID(const UnicodeString& id) { 1318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ID = id; 1319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // NUL-terminate the ID string, which is a non-aliased copy. 1320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ID.append((UChar)0); 1321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ID.truncate(ID.length()-1); 1322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 1323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 132459d709d503bab6e2b61931737e662dd293b40578ccornelius#ifndef U_HIDE_INTERNAL_API 1325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline Transliterator::Token Transliterator::integerToken(int32_t i) { 1326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Token t; 1327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru t.integer = i; 1328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return t; 1329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 1330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline Transliterator::Token Transliterator::pointerToken(void* p) { 1332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Token t; 1333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru t.pointer = p; 1334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return t; 1335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 133659d709d503bab6e2b61931737e662dd293b40578ccornelius#endif /* U_HIDE_INTERNAL_API */ 1337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END 1339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif /* #if !UCONFIG_NO_TRANSLITERATION */ 1341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 1342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 1343