Home | History | Annotate | Download | only in unicode
      1 /*
      2 **********************************************************************
      3 *   Copyright (c) 2002-2005, International Business Machines Corporation
      4 *   and others.  All Rights Reserved.
      5 **********************************************************************
      6 *   Date        Name        Description
      7 *   01/14/2002  aliu        Creation.
      8 **********************************************************************
      9 */
     10 #ifndef UNIFUNCT_H
     11 #define UNIFUNCT_H
     12 
     13 #include "unicode/utypes.h"
     14 #include "unicode/uobject.h"
     15 
     16 /**
     17  * \file
     18  * \brief C++ API: Unicode Functor
     19  */
     20 
     21 U_NAMESPACE_BEGIN
     22 
     23 class UnicodeMatcher;
     24 class UnicodeReplacer;
     25 class TransliterationRuleData;
     26 
     27 /**
     28  * <code>UnicodeFunctor</code> is an abstract base class for objects
     29  * that perform match and/or replace operations on Unicode strings.
     30  * @author Alan Liu
     31  * @stable ICU 2.4
     32  */
     33 class U_COMMON_API UnicodeFunctor : public UObject {
     34 
     35 public:
     36 
     37     /**
     38      * Destructor
     39      * @stable ICU 2.4
     40      */
     41     virtual ~UnicodeFunctor();
     42 
     43     /**
     44      * Return a copy of this object.  All UnicodeFunctor objects
     45      * have to support cloning in order to allow classes using
     46      * UnicodeFunctor to implement cloning.
     47      * @stable ICU 2.4
     48      */
     49     virtual UnicodeFunctor* clone() const = 0;
     50 
     51     /**
     52      * Cast 'this' to a UnicodeMatcher* pointer and return the
     53      * pointer, or null if this is not a UnicodeMatcher*.  Subclasses
     54      * that mix in UnicodeMatcher as a base class must override this.
     55      * This protocol is required because a pointer to a UnicodeFunctor
     56      * cannot be cast to a pointer to a UnicodeMatcher, since
     57      * UnicodeMatcher is a mixin that does not derive from
     58      * UnicodeFunctor.
     59      * @stable ICU 2.4
     60      */
     61     virtual UnicodeMatcher* toMatcher() const;
     62 
     63     /**
     64      * Cast 'this' to a UnicodeReplacer* pointer and return the
     65      * pointer, or null if this is not a UnicodeReplacer*.  Subclasses
     66      * that mix in UnicodeReplacer as a base class must override this.
     67      * This protocol is required because a pointer to a UnicodeFunctor
     68      * cannot be cast to a pointer to a UnicodeReplacer, since
     69      * UnicodeReplacer is a mixin that does not derive from
     70      * UnicodeFunctor.
     71      * @stable ICU 2.4
     72      */
     73     virtual UnicodeReplacer* toReplacer() const;
     74 
     75     /**
     76      * Return the class ID for this class.  This is useful only for
     77      * comparing to a return value from getDynamicClassID().
     78      * @return          The class ID for all objects of this class.
     79      * @stable ICU 2.0
     80      */
     81     static UClassID U_EXPORT2 getStaticClassID(void);
     82 
     83     /**
     84      * Returns a unique class ID <b>polymorphically</b>.  This method
     85      * is to implement a simple version of RTTI, since not all C++
     86      * compilers support genuine RTTI.  Polymorphic operator==() and
     87      * clone() methods call this method.
     88      *
     89      * <p>Concrete subclasses of UnicodeFunctor should use the macro
     90      *    UOBJECT_DEFINE_RTTI_IMPLEMENTATION from uobject.h to
     91      *    provide definitios getStaticClassID and getDynamicClassID.
     92      *
     93      * @return The class ID for this object. All objects of a given
     94      * class have the same class ID.  Objects of other classes have
     95      * different class IDs.
     96      * @stable ICU 2.4
     97      */
     98     virtual UClassID getDynamicClassID(void) const = 0;
     99 
    100     /**
    101      * Set the data object associated with this functor.  The data
    102      * object provides context for functor-to-standin mapping.  This
    103      * method is required when assigning a functor to a different data
    104      * object.  This function MAY GO AWAY later if the architecture is
    105      * changed to pass data object pointers through the API.
    106      * @internal ICU 2.1
    107      */
    108     virtual void setData(const TransliterationRuleData*) = 0;
    109 
    110 protected:
    111 
    112     /**
    113      * Since this class has pure virtual functions,
    114      * a constructor can't be used.
    115      * @stable ICU 2.0
    116      */
    117     /*UnicodeFunctor();*/
    118 
    119 };
    120 
    121 /*inline UnicodeFunctor::UnicodeFunctor() {}*/
    122 
    123 U_NAMESPACE_END
    124 
    125 #endif
    126