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