unifunct.h 4.0 KB

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