nortrans.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. **********************************************************************
  5. * Copyright (C) 2001-2010, International Business Machines
  6. * Corporation and others. All Rights Reserved.
  7. **********************************************************************
  8. * Date Name Description
  9. * 07/03/01 aliu Creation.
  10. **********************************************************************
  11. */
  12. #ifndef NORTRANS_H
  13. #define NORTRANS_H
  14. #include "unicode/utypes.h"
  15. #if !UCONFIG_NO_TRANSLITERATION
  16. #include "unicode/translit.h"
  17. #include "unicode/normalizer2.h"
  18. U_NAMESPACE_BEGIN
  19. /**
  20. * A transliterator that performs normalization.
  21. * @author Alan Liu
  22. */
  23. class NormalizationTransliterator : public Transliterator {
  24. const Normalizer2 &fNorm2;
  25. public:
  26. /**
  27. * Destructor.
  28. */
  29. virtual ~NormalizationTransliterator();
  30. /**
  31. * Copy constructor.
  32. */
  33. NormalizationTransliterator(const NormalizationTransliterator&);
  34. /**
  35. * Transliterator API.
  36. * @return A copy of the object.
  37. */
  38. virtual NormalizationTransliterator* clone() const override;
  39. /**
  40. * ICU "poor man's RTTI", returns a UClassID for the actual class.
  41. */
  42. virtual UClassID getDynamicClassID() const override;
  43. /**
  44. * ICU "poor man's RTTI", returns a UClassID for this class.
  45. */
  46. U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
  47. protected:
  48. /**
  49. * Implements {@link Transliterator#handleTransliterate}.
  50. * @param text the buffer holding transliterated and
  51. * untransliterated text
  52. * @param offset the start and limit of the text, the position
  53. * of the cursor, and the start and limit of transliteration.
  54. * @param incremental if true, assume more text may be coming after
  55. * pos.contextLimit. Otherwise, assume the text is complete.
  56. */
  57. virtual void handleTransliterate(Replaceable& text, UTransPosition& offset,
  58. UBool isIncremental) const override;
  59. public:
  60. /**
  61. * System registration hook. Public to Transliterator only.
  62. */
  63. static void registerIDs();
  64. private:
  65. // Transliterator::Factory methods
  66. static Transliterator* _create(const UnicodeString& ID,
  67. Token context);
  68. /**
  69. * Constructs a transliterator. This method is private.
  70. * Public users must use the factory method createInstance().
  71. */
  72. NormalizationTransliterator(const UnicodeString& id, const Normalizer2 &norm2);
  73. private:
  74. /**
  75. * Assignment operator.
  76. */
  77. NormalizationTransliterator& operator=(const NormalizationTransliterator&);
  78. };
  79. U_NAMESPACE_END
  80. #endif /* #if !UCONFIG_NO_TRANSLITERATION */
  81. #endif