2 **********************************************************************
3 * Copyright (c) 2002-2004, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 **********************************************************************
6 * Date Name Description
7 * 01/14/2002 aliu Creation.
8 **********************************************************************
13 #include "unicode/utypes.h"
22 * <code>UnicodeReplacer</code> defines a protocol for objects that
23 * replace a range of characters in a Replaceable string with output
24 * text. The replacement is done via the Replaceable API so as to
25 * preserve out-of-band data.
27 * <p>This is a mixin class.
31 class U_I18N_API UnicodeReplacer
/* not : public UObject because this is an interface/mixin class */ {
39 virtual ~UnicodeReplacer();
42 * Replace characters in 'text' from 'start' to 'limit' with the
43 * output text of this object. Update the 'cursor' parameter to
44 * give the cursor position and return the length of the
47 * @param text the text to be matched
48 * @param start inclusive start index of text to be replaced
49 * @param limit exclusive end index of text to be replaced;
50 * must be greater than or equal to start
51 * @param cursor output parameter for the cursor position.
52 * Not all replacer objects will update this, but in a complete
53 * tree of replacer objects, representing the entire output side
54 * of a transliteration rule, at least one must update it.
55 * @return the number of 16-bit code units in the text replacing
56 * the characters at offsets start..(limit-1) in text
59 virtual int32_t replace(Replaceable
& text
,
65 * Returns a string representation of this replacer. If the
66 * result of calling this function is passed to the appropriate
67 * parser, typically TransliteratorParser, it will produce another
68 * replacer that is equal to this one.
69 * @param result the string to receive the pattern. Previous
70 * contents will be deleted.
71 * @param escapeUnprintable if TRUE then convert unprintable
72 * character to their hex escape representations, \\uxxxx or
73 * \\Uxxxxxxxx. Unprintable characters are defined by
74 * Utility.isUnprintable().
75 * @return a reference to 'result'.
78 virtual UnicodeString
& toReplacerPattern(UnicodeString
& result
,
79 UBool escapeUnprintable
) const = 0;
82 * Union the set of all characters that may output by this object
84 * @param toUnionTo the set into which to union the output characters
87 virtual void addReplacementSetTo(UnicodeSet
& toUnionTo
) const = 0;