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