brktrans.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. **********************************************************************
  5. * Copyright (C) 2008-2015, International Business Machines
  6. * Corporation and others. All Rights Reserved.
  7. **********************************************************************
  8. * Date Name Description
  9. * 05/11/2008 Andy Heninger Ported from Java
  10. **********************************************************************
  11. */
  12. #ifndef BRKTRANS_H
  13. #define BRKTRANS_H
  14. #include "unicode/utypes.h"
  15. #if !UCONFIG_NO_TRANSLITERATION && !UCONFIG_NO_BREAK_ITERATION
  16. #include "unicode/translit.h"
  17. #include "unicode/localpointer.h"
  18. U_NAMESPACE_BEGIN
  19. class UVector32;
  20. /**
  21. * A transliterator that pInserts the specified characters at word breaks.
  22. * To restrict it to particular characters, use a filter.
  23. * TODO: this is an internal class, and only temporary.
  24. * Remove it once we have \b notation in Transliterator.
  25. */
  26. class BreakTransliterator : public Transliterator {
  27. public:
  28. /**
  29. * Constructs a transliterator.
  30. * @param adoptedFilter the filter for this transliterator.
  31. */
  32. BreakTransliterator(UnicodeFilter* adoptedFilter = 0);
  33. /**
  34. * Destructor.
  35. */
  36. virtual ~BreakTransliterator();
  37. /**
  38. * Copy constructor.
  39. */
  40. BreakTransliterator(const BreakTransliterator&);
  41. /**
  42. * Transliterator API.
  43. * @return A copy of the object.
  44. */
  45. virtual BreakTransliterator* clone() const;
  46. virtual const UnicodeString &getInsertion() const;
  47. virtual void setInsertion(const UnicodeString &insertion);
  48. /**
  49. * ICU "poor man's RTTI", returns a UClassID for the actual class.
  50. */
  51. virtual UClassID getDynamicClassID() const;
  52. /**
  53. * ICU "poor man's RTTI", returns a UClassID for this class.
  54. */
  55. U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
  56. protected:
  57. /**
  58. * Implements {@link Transliterator#handleTransliterate}.
  59. * @param text the buffer holding transliterated and
  60. * untransliterated text
  61. * @param offset the start and limit of the text, the position
  62. * of the cursor, and the start and limit of transliteration.
  63. * @param incremental if true, assume more text may be coming after
  64. * pos.contextLimit. Otherwise, assume the text is complete.
  65. */
  66. virtual void handleTransliterate(Replaceable& text, UTransPosition& offset,
  67. UBool isIncremental) const;
  68. private:
  69. LocalPointer<BreakIterator> cachedBI;
  70. LocalPointer<UVector32> cachedBoundaries;
  71. UnicodeString fInsertion;
  72. static UnicodeString replaceableAsString(Replaceable &r);
  73. /**
  74. * Assignment operator.
  75. */
  76. BreakTransliterator& operator=(const BreakTransliterator&);
  77. };
  78. U_NAMESPACE_END
  79. #endif /* #if !UCONFIG_NO_TRANSLITERATION */
  80. #endif