]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/funcrepl.h
ICU-62141.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / funcrepl.h
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
b75a7d8f
A
3/*
4**********************************************************************
4388f060 5* Copyright (c) 2002-2011, International Business Machines Corporation
b75a7d8f
A
6* and others. All Rights Reserved.
7**********************************************************************
8* Date Name Description
9* 02/04/2002 aliu Creation.
10**********************************************************************
11*/
12
73c04bcf
A
13#ifndef FUNCREPL_H
14#define FUNCREPL_H
15
b75a7d8f
A
16#include "unicode/utypes.h"
17
18#if !UCONFIG_NO_TRANSLITERATION
19
20#include "unicode/unifunct.h"
21#include "unicode/unirepl.h"
22
23U_NAMESPACE_BEGIN
24
25class Transliterator;
26
27/**
28 * A replacer that calls a transliterator to generate its output text.
29 * The input text to the transliterator is the output of another
30 * UnicodeReplacer object. That is, this replacer wraps another
31 * replacer with a transliterator.
32 *
b75a7d8f
A
33 * @author Alan Liu
34 */
46f4442e 35class FunctionReplacer : public UnicodeFunctor, public UnicodeReplacer {
b75a7d8f
A
36
37 private:
38
39 /**
40 * The transliterator. Must not be null. OWNED.
41 */
42 Transliterator* translit;
43
44 /**
45 * The replacer object. This generates text that is then
46 * processed by 'translit'. Must not be null. OWNED.
47 */
48 UnicodeFunctor* replacer;
49
b75a7d8f
A
50 public:
51
52 /**
53 * Construct a replacer that takes the output of the given
54 * replacer, passes it through the given transliterator, and emits
55 * the result as output.
56 */
57 FunctionReplacer(Transliterator* adoptedTranslit,
58 UnicodeFunctor* adoptedReplacer);
59
60 /**
61 * Copy constructor.
62 */
63 FunctionReplacer(const FunctionReplacer& other);
64
65 /**
66 * Destructor
67 */
68 virtual ~FunctionReplacer();
69
70 /**
71 * Implement UnicodeFunctor
72 */
73 virtual UnicodeFunctor* clone() const;
74
75 /**
76 * UnicodeFunctor API. Cast 'this' to a UnicodeReplacer* pointer
77 * and return the pointer.
78 */
79 virtual UnicodeReplacer* toReplacer() const;
80
81 /**
82 * UnicodeReplacer API
83 */
84 virtual int32_t replace(Replaceable& text,
85 int32_t start,
86 int32_t limit,
87 int32_t& cursor);
88
89 /**
90 * UnicodeReplacer API
91 */
92 virtual UnicodeString& toReplacerPattern(UnicodeString& rule,
93 UBool escapeUnprintable) const;
94
95 /**
96 * Implement UnicodeReplacer
97 */
98 virtual void addReplacementSetTo(UnicodeSet& toUnionTo) const;
99
100 /**
101 * UnicodeFunctor API
102 */
103 virtual void setData(const TransliterationRuleData*);
104
105 /**
106 * ICU "poor man's RTTI", returns a UClassID for the actual class.
b75a7d8f 107 */
374ca955 108 virtual UClassID getDynamicClassID() const;
b75a7d8f
A
109
110 /**
111 * ICU "poor man's RTTI", returns a UClassID for this class.
b75a7d8f 112 */
374ca955 113 static UClassID U_EXPORT2 getStaticClassID();
b75a7d8f
A
114};
115
116U_NAMESPACE_END
117
118#endif /* #if !UCONFIG_NO_TRANSLITERATION */
73c04bcf 119#endif
b75a7d8f
A
120
121//eof