unifunct.h 4.1 KB

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