2016-06-15 18:58:17 +00:00
|
|
|
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
|
|
|
// License & terms of use: http://www.unicode.org/copyright.html
|
2002-02-07 01:07:55 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
2016-05-31 21:45:07 +00:00
|
|
|
* Copyright (c) 2002-2011, International Business Machines Corporation
|
|
|
|
* and others. All Rights Reserved.
|
2002-02-07 01:07:55 +00:00
|
|
|
**********************************************************************
|
|
|
|
* Date Name Description
|
|
|
|
* 02/04/2002 aliu Creation.
|
|
|
|
**********************************************************************
|
|
|
|
*/
|
2002-09-20 01:54:48 +00:00
|
|
|
|
2004-12-07 23:43:48 +00:00
|
|
|
#ifndef FUNCREPL_H
|
|
|
|
#define FUNCREPL_H
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
|
|
|
#if !UCONFIG_NO_TRANSLITERATION
|
|
|
|
|
2002-02-07 01:07:55 +00:00
|
|
|
#include "unicode/unifunct.h"
|
|
|
|
#include "unicode/unirepl.h"
|
|
|
|
|
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class Transliterator;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A replacer that calls a transliterator to generate its output text.
|
|
|
|
* The input text to the transliterator is the output of another
|
|
|
|
* UnicodeReplacer object. That is, this replacer wraps another
|
|
|
|
* replacer with a transliterator.
|
2002-12-17 21:26:31 +00:00
|
|
|
*
|
2002-02-07 01:07:55 +00:00
|
|
|
* @author Alan Liu
|
|
|
|
*/
|
2007-06-14 19:03:30 +00:00
|
|
|
class FunctionReplacer : public UnicodeFunctor, public UnicodeReplacer {
|
2002-02-07 01:07:55 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The transliterator. Must not be null. OWNED.
|
|
|
|
*/
|
|
|
|
Transliterator* translit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The replacer object. This generates text that is then
|
|
|
|
* processed by 'translit'. Must not be null. OWNED.
|
|
|
|
*/
|
|
|
|
UnicodeFunctor* replacer;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct a replacer that takes the output of the given
|
|
|
|
* replacer, passes it through the given transliterator, and emits
|
|
|
|
* the result as output.
|
|
|
|
*/
|
|
|
|
FunctionReplacer(Transliterator* adoptedTranslit,
|
|
|
|
UnicodeFunctor* adoptedReplacer);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy constructor.
|
|
|
|
*/
|
|
|
|
FunctionReplacer(const FunctionReplacer& other);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
virtual ~FunctionReplacer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implement UnicodeFunctor
|
|
|
|
*/
|
|
|
|
virtual UnicodeFunctor* clone() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UnicodeFunctor API. Cast 'this' to a UnicodeReplacer* pointer
|
|
|
|
* and return the pointer.
|
|
|
|
*/
|
|
|
|
virtual UnicodeReplacer* toReplacer() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UnicodeReplacer API
|
|
|
|
*/
|
|
|
|
virtual int32_t replace(Replaceable& text,
|
|
|
|
int32_t start,
|
|
|
|
int32_t limit,
|
|
|
|
int32_t& cursor);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UnicodeReplacer API
|
|
|
|
*/
|
|
|
|
virtual UnicodeString& toReplacerPattern(UnicodeString& rule,
|
|
|
|
UBool escapeUnprintable) const;
|
2002-03-20 00:42:02 +00:00
|
|
|
|
2002-06-28 21:13:54 +00:00
|
|
|
/**
|
|
|
|
* Implement UnicodeReplacer
|
|
|
|
*/
|
|
|
|
virtual void addReplacementSetTo(UnicodeSet& toUnionTo) const;
|
|
|
|
|
2002-03-20 00:42:02 +00:00
|
|
|
/**
|
|
|
|
* UnicodeFunctor API
|
|
|
|
*/
|
|
|
|
virtual void setData(const TransliterationRuleData*);
|
2002-06-29 00:04:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
|
|
|
*/
|
2003-08-31 20:53:46 +00:00
|
|
|
virtual UClassID getDynamicClassID() const;
|
2002-06-29 00:04:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ICU "poor man's RTTI", returns a UClassID for this class.
|
|
|
|
*/
|
2004-08-24 17:38:33 +00:00
|
|
|
static UClassID U_EXPORT2 getStaticClassID();
|
2002-02-07 01:07:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_TRANSLITERATION */
|
2004-12-07 23:43:48 +00:00
|
|
|
#endif
|
2002-09-20 01:54:48 +00:00
|
|
|
|
2002-02-07 01:07:55 +00:00
|
|
|
//eof
|