]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/strrepl.h
2 **********************************************************************
3 * Copyright (c) 2002-2011, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 **********************************************************************
6 * Date Name Description
7 * 01/21/2002 aliu Creation.
8 **********************************************************************
14 #include "unicode/utypes.h"
16 #if !UCONFIG_NO_TRANSLITERATION
18 #include "unicode/unifunct.h"
19 #include "unicode/unirepl.h"
20 #include "unicode/unistr.h"
24 class TransliterationRuleData
;
27 * A replacer that produces static text as its output. The text may
28 * contain transliterator stand-in characters that represent nested
29 * UnicodeReplacer objects, making it possible to encode a tree of
30 * replacers in a StringReplacer. A StringReplacer that contains such
31 * stand-ins is called a <em>complex</em> StringReplacer. A complex
32 * StringReplacer has a slower processing loop than a non-complex one.
35 class StringReplacer
: public UnicodeFunctor
, public UnicodeReplacer
{
40 * Output text, possibly containing stand-in characters that
41 * represent nested UnicodeReplacers.
46 * Cursor position. Value is ignored if hasCursor is false.
51 * True if this object outputs a cursor position.
56 * A complex object contains nested replacers and requires more
57 * complex processing. StringReplacers are initially assumed to
58 * be complex. If no nested replacers are seen during processing,
59 * then isComplex is set to false, and future replacements are
60 * short circuited for better performance.
65 * Object that translates stand-in characters in 'output' to
66 * UnicodeReplacer objects.
68 const TransliterationRuleData
* data
;
73 * Construct a StringReplacer that sets the emits the given output
74 * text and sets the cursor to the given position.
75 * @param theOutput text that will replace input text when the
76 * replace() method is called. May contain stand-in characters
77 * that represent nested replacers.
78 * @param theCursorPos cursor position that will be returned by
79 * the replace() method
80 * @param theData transliterator context object that translates
81 * stand-in characters to UnicodeReplacer objects
83 StringReplacer(const UnicodeString
& theOutput
,
85 const TransliterationRuleData
* theData
);
88 * Construct a StringReplacer that sets the emits the given output
89 * text and does not modify the cursor.
90 * @param theOutput text that will replace input text when the
91 * replace() method is called. May contain stand-in characters
92 * that represent nested replacers.
93 * @param theData transliterator context object that translates
94 * stand-in characters to UnicodeReplacer objects
96 StringReplacer(const UnicodeString
& theOutput
,
97 const TransliterationRuleData
* theData
);
102 StringReplacer(const StringReplacer
& other
);
107 virtual ~StringReplacer();
110 * Implement UnicodeFunctor
112 virtual UnicodeFunctor
* clone() const;
115 * UnicodeFunctor API. Cast 'this' to a UnicodeReplacer* pointer
116 * and return the pointer.
118 virtual UnicodeReplacer
* toReplacer() const;
121 * UnicodeReplacer API
123 virtual int32_t replace(Replaceable
& text
,
129 * UnicodeReplacer API
131 virtual UnicodeString
& toReplacerPattern(UnicodeString
& result
,
132 UBool escapeUnprintable
) const;
135 * Implement UnicodeReplacer
137 virtual void addReplacementSetTo(UnicodeSet
& toUnionTo
) const;
142 virtual void setData(const TransliterationRuleData
*);
145 * ICU "poor man's RTTI", returns a UClassID for this class.
147 static UClassID U_EXPORT2
getStaticClassID();
150 * ICU "poor man's RTTI", returns a UClassID for the actual class.
152 virtual UClassID
getDynamicClassID() const;
157 #endif /* #if !UCONFIG_NO_TRANSLITERATION */