intl/icu/source/i18n/funcrepl.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/i18n/funcrepl.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,119 @@
     1.4 +/*
     1.5 +**********************************************************************
     1.6 +*   Copyright (c) 2002-2011, International Business Machines Corporation
     1.7 +*   and others.  All Rights Reserved.
     1.8 +**********************************************************************
     1.9 +*   Date        Name        Description
    1.10 +*   02/04/2002  aliu        Creation.
    1.11 +**********************************************************************
    1.12 +*/
    1.13 +
    1.14 +#ifndef FUNCREPL_H
    1.15 +#define FUNCREPL_H
    1.16 +
    1.17 +#include "unicode/utypes.h"
    1.18 +
    1.19 +#if !UCONFIG_NO_TRANSLITERATION
    1.20 +
    1.21 +#include "unicode/unifunct.h"
    1.22 +#include "unicode/unirepl.h"
    1.23 +
    1.24 +U_NAMESPACE_BEGIN
    1.25 +
    1.26 +class Transliterator;
    1.27 +
    1.28 +/**
    1.29 + * A replacer that calls a transliterator to generate its output text.
    1.30 + * The input text to the transliterator is the output of another
    1.31 + * UnicodeReplacer object.  That is, this replacer wraps another
    1.32 + * replacer with a transliterator.
    1.33 + *
    1.34 + * @author Alan Liu
    1.35 + */
    1.36 +class FunctionReplacer : public UnicodeFunctor, public UnicodeReplacer {
    1.37 +
    1.38 + private:
    1.39 +
    1.40 +    /**
    1.41 +     * The transliterator.  Must not be null.  OWNED.
    1.42 +     */
    1.43 +    Transliterator* translit;
    1.44 +
    1.45 +    /**
    1.46 +     * The replacer object.  This generates text that is then
    1.47 +     * processed by 'translit'.  Must not be null.  OWNED.
    1.48 +     */
    1.49 +    UnicodeFunctor* replacer;
    1.50 +
    1.51 + public:
    1.52 +
    1.53 +    /**
    1.54 +     * Construct a replacer that takes the output of the given
    1.55 +     * replacer, passes it through the given transliterator, and emits
    1.56 +     * the result as output.
    1.57 +     */
    1.58 +    FunctionReplacer(Transliterator* adoptedTranslit,
    1.59 +                     UnicodeFunctor* adoptedReplacer);
    1.60 +
    1.61 +    /**
    1.62 +     * Copy constructor.
    1.63 +     */
    1.64 +    FunctionReplacer(const FunctionReplacer& other);
    1.65 +
    1.66 +    /**
    1.67 +     * Destructor
    1.68 +     */
    1.69 +    virtual ~FunctionReplacer();
    1.70 +
    1.71 +    /**
    1.72 +     * Implement UnicodeFunctor
    1.73 +     */
    1.74 +    virtual UnicodeFunctor* clone() const;
    1.75 +
    1.76 +    /**
    1.77 +     * UnicodeFunctor API.  Cast 'this' to a UnicodeReplacer* pointer
    1.78 +     * and return the pointer.
    1.79 +     */
    1.80 +    virtual UnicodeReplacer* toReplacer() const;
    1.81 +
    1.82 +    /**
    1.83 +     * UnicodeReplacer API
    1.84 +     */
    1.85 +    virtual int32_t replace(Replaceable& text,
    1.86 +                            int32_t start,
    1.87 +                            int32_t limit,
    1.88 +                            int32_t& cursor);
    1.89 +
    1.90 +    /**
    1.91 +     * UnicodeReplacer API
    1.92 +     */
    1.93 +    virtual UnicodeString& toReplacerPattern(UnicodeString& rule,
    1.94 +                                             UBool escapeUnprintable) const;
    1.95 +
    1.96 +    /**
    1.97 +     * Implement UnicodeReplacer
    1.98 +     */
    1.99 +    virtual void addReplacementSetTo(UnicodeSet& toUnionTo) const;
   1.100 +
   1.101 +    /**
   1.102 +     * UnicodeFunctor API
   1.103 +     */
   1.104 +    virtual void setData(const TransliterationRuleData*);
   1.105 +
   1.106 +    /**
   1.107 +     * ICU "poor man's RTTI", returns a UClassID for the actual class.
   1.108 +     */
   1.109 +    virtual UClassID getDynamicClassID() const;
   1.110 +
   1.111 +    /**
   1.112 +     * ICU "poor man's RTTI", returns a UClassID for this class.
   1.113 +     */
   1.114 +    static UClassID U_EXPORT2 getStaticClassID();
   1.115 +};
   1.116 +
   1.117 +U_NAMESPACE_END
   1.118 +
   1.119 +#endif /* #if !UCONFIG_NO_TRANSLITERATION */
   1.120 +#endif
   1.121 +
   1.122 +//eof

mercurial