michael@0: /* michael@0: ********************************************************************** michael@0: * Copyright (c) 2002-2011, International Business Machines Corporation michael@0: * and others. All Rights Reserved. michael@0: ********************************************************************** michael@0: * Date Name Description michael@0: * 02/04/2002 aliu Creation. michael@0: ********************************************************************** michael@0: */ michael@0: michael@0: #ifndef FUNCREPL_H michael@0: #define FUNCREPL_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_TRANSLITERATION michael@0: michael@0: #include "unicode/unifunct.h" michael@0: #include "unicode/unirepl.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: class Transliterator; michael@0: michael@0: /** michael@0: * A replacer that calls a transliterator to generate its output text. michael@0: * The input text to the transliterator is the output of another michael@0: * UnicodeReplacer object. That is, this replacer wraps another michael@0: * replacer with a transliterator. michael@0: * michael@0: * @author Alan Liu michael@0: */ michael@0: class FunctionReplacer : public UnicodeFunctor, public UnicodeReplacer { michael@0: michael@0: private: michael@0: michael@0: /** michael@0: * The transliterator. Must not be null. OWNED. michael@0: */ michael@0: Transliterator* translit; michael@0: michael@0: /** michael@0: * The replacer object. This generates text that is then michael@0: * processed by 'translit'. Must not be null. OWNED. michael@0: */ michael@0: UnicodeFunctor* replacer; michael@0: michael@0: public: michael@0: michael@0: /** michael@0: * Construct a replacer that takes the output of the given michael@0: * replacer, passes it through the given transliterator, and emits michael@0: * the result as output. michael@0: */ michael@0: FunctionReplacer(Transliterator* adoptedTranslit, michael@0: UnicodeFunctor* adoptedReplacer); michael@0: michael@0: /** michael@0: * Copy constructor. michael@0: */ michael@0: FunctionReplacer(const FunctionReplacer& other); michael@0: michael@0: /** michael@0: * Destructor michael@0: */ michael@0: virtual ~FunctionReplacer(); michael@0: michael@0: /** michael@0: * Implement UnicodeFunctor michael@0: */ michael@0: virtual UnicodeFunctor* clone() const; michael@0: michael@0: /** michael@0: * UnicodeFunctor API. Cast 'this' to a UnicodeReplacer* pointer michael@0: * and return the pointer. michael@0: */ michael@0: virtual UnicodeReplacer* toReplacer() const; michael@0: michael@0: /** michael@0: * UnicodeReplacer API michael@0: */ michael@0: virtual int32_t replace(Replaceable& text, michael@0: int32_t start, michael@0: int32_t limit, michael@0: int32_t& cursor); michael@0: michael@0: /** michael@0: * UnicodeReplacer API michael@0: */ michael@0: virtual UnicodeString& toReplacerPattern(UnicodeString& rule, michael@0: UBool escapeUnprintable) const; michael@0: michael@0: /** michael@0: * Implement UnicodeReplacer michael@0: */ michael@0: virtual void addReplacementSetTo(UnicodeSet& toUnionTo) const; michael@0: michael@0: /** michael@0: * UnicodeFunctor API michael@0: */ michael@0: virtual void setData(const TransliterationRuleData*); michael@0: michael@0: /** michael@0: * ICU "poor man's RTTI", returns a UClassID for the actual class. michael@0: */ michael@0: virtual UClassID getDynamicClassID() const; michael@0: michael@0: /** michael@0: * ICU "poor man's RTTI", returns a UClassID for this class. michael@0: */ michael@0: static UClassID U_EXPORT2 getStaticClassID(); michael@0: }; michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* #if !UCONFIG_NO_TRANSLITERATION */ michael@0: #endif michael@0: michael@0: //eof