unifilt.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. **********************************************************************
  5. * Copyright (C) 1999-2010, International Business Machines Corporation and others.
  6. * All Rights Reserved.
  7. **********************************************************************
  8. * Date Name Description
  9. * 11/17/99 aliu Creation.
  10. **********************************************************************
  11. */
  12. #ifndef UNIFILT_H
  13. #define UNIFILT_H
  14. #include "unicode/utypes.h"
  15. #if U_SHOW_CPLUSPLUS_API
  16. #include "unicode/unifunct.h"
  17. #include "unicode/unimatch.h"
  18. /**
  19. * \file
  20. * \brief C++ API: Unicode Filter
  21. */
  22. U_NAMESPACE_BEGIN
  23. /**
  24. * U_ETHER is used to represent character values for positions outside
  25. * a range. For example, transliterator uses this to represent
  26. * characters outside the range contextStart..contextLimit-1. This
  27. * allows explicit matching by rules and UnicodeSets of text outside a
  28. * defined range.
  29. * @stable ICU 3.0
  30. */
  31. #define U_ETHER ((char16_t)0xFFFF)
  32. /**
  33. *
  34. * <code>UnicodeFilter</code> defines a protocol for selecting a
  35. * subset of the full range (U+0000 to U+10FFFF) of Unicode characters.
  36. * Currently, filters are used in conjunction with classes like
  37. * {@link Transliterator} to only process selected characters through a
  38. * transformation.
  39. *
  40. * <p>Note: UnicodeFilter currently stubs out two pure virtual methods
  41. * of its base class, UnicodeMatcher. These methods are toPattern()
  42. * and matchesIndexValue(). This is done so that filter classes that
  43. * are not actually used as matchers -- specifically, those in the
  44. * UnicodeFilterLogic component, and those in tests -- can continue to
  45. * work without defining these methods. As long as a filter is not
  46. * used in an RBT during real transliteration, these methods will not
  47. * be called. However, this breaks the UnicodeMatcher base class
  48. * protocol, and it is not a correct solution.
  49. *
  50. * <p>In the future we may revisit the UnicodeMatcher / UnicodeFilter
  51. * hierarchy and either redesign it, or simply remove the stubs in
  52. * UnicodeFilter and force subclasses to implement the full
  53. * UnicodeMatcher protocol.
  54. *
  55. * @see UnicodeFilterLogic
  56. * @stable ICU 2.0
  57. */
  58. class U_COMMON_API UnicodeFilter : public UnicodeFunctor, public UnicodeMatcher {
  59. public:
  60. /**
  61. * Destructor
  62. * @stable ICU 2.0
  63. */
  64. virtual ~UnicodeFilter();
  65. /**
  66. * Clones this object polymorphically.
  67. * The caller owns the result and should delete it when done.
  68. * @return clone, or nullptr if an error occurred
  69. * @stable ICU 2.4
  70. */
  71. virtual UnicodeFilter* clone() const override = 0;
  72. /**
  73. * Returns <tt>true</tt> for characters that are in the selected
  74. * subset. In other words, if a character is <b>to be
  75. * filtered</b>, then <tt>contains()</tt> returns
  76. * <b><tt>false</tt></b>.
  77. * @stable ICU 2.0
  78. */
  79. virtual UBool contains(UChar32 c) const = 0;
  80. /**
  81. * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer
  82. * and return the pointer.
  83. * @stable ICU 2.4
  84. */
  85. virtual UnicodeMatcher* toMatcher() const override;
  86. /**
  87. * Implement UnicodeMatcher API.
  88. * @stable ICU 2.4
  89. */
  90. virtual UMatchDegree matches(const Replaceable& text,
  91. int32_t& offset,
  92. int32_t limit,
  93. UBool incremental) override;
  94. /**
  95. * UnicodeFunctor API. Nothing to do.
  96. * @stable ICU 2.4
  97. */
  98. virtual void setData(const TransliterationRuleData*) override;
  99. /**
  100. * ICU "poor man's RTTI", returns a UClassID for this class.
  101. *
  102. * @stable ICU 2.2
  103. */
  104. static UClassID U_EXPORT2 getStaticClassID();
  105. protected:
  106. /*
  107. * Since this class has pure virtual functions,
  108. * a constructor can't be used.
  109. * @stable ICU 2.0
  110. */
  111. /* UnicodeFilter();*/
  112. };
  113. /*inline UnicodeFilter::UnicodeFilter() {}*/
  114. U_NAMESPACE_END
  115. #endif /* U_SHOW_CPLUSPLUS_API */
  116. #endif