| OLD | NEW |
| 1 /* | 1 /* |
| 2 ********************************************************************** | 2 ********************************************************************** |
| 3 * Copyright (C) 2008-2009, International Business Machines | 3 * Copyright (C) 2008-2015, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
| 5 ********************************************************************** | 5 ********************************************************************** |
| 6 * Date Name Description | 6 * Date Name Description |
| 7 * 05/11/2008 Andy Heninger Ported from Java | 7 * 05/11/2008 Andy Heninger Ported from Java |
| 8 ********************************************************************** | 8 ********************************************************************** |
| 9 */ | 9 */ |
| 10 #ifndef BRKTRANS_H | 10 #ifndef BRKTRANS_H |
| 11 #define BRKTRANS_H | 11 #define BRKTRANS_H |
| 12 | 12 |
| 13 #include "unicode/utypes.h" | 13 #include "unicode/utypes.h" |
| 14 | 14 |
| 15 #if !UCONFIG_NO_TRANSLITERATION && !UCONFIG_NO_BREAK_ITERATION | 15 #if !UCONFIG_NO_TRANSLITERATION && !UCONFIG_NO_BREAK_ITERATION |
| 16 | 16 |
| 17 #include "unicode/translit.h" | 17 #include "unicode/translit.h" |
| 18 | 18 |
| 19 #include "unicode/localpointer.h" |
| 20 |
| 19 | 21 |
| 20 U_NAMESPACE_BEGIN | 22 U_NAMESPACE_BEGIN |
| 21 | 23 |
| 22 class UVector32; | 24 class UVector32; |
| 23 | 25 |
| 24 /** | 26 /** |
| 25 * A transliterator that pInserts the specified characters at word breaks. | 27 * A transliterator that pInserts the specified characters at word breaks. |
| 26 * To restrict it to particular characters, use a filter. | 28 * To restrict it to particular characters, use a filter. |
| 27 * TODO: this is an internal class, and only temporary. | 29 * TODO: this is an internal class, and only temporary. |
| 28 * Remove it once we have \b notation in Transliterator. | 30 * Remove it once we have \b notation in Transliterator. |
| 29 */ | 31 */ |
| 30 class BreakTransliterator : public Transliterator { | 32 class BreakTransliterator : public Transliterator { |
| 31 public: | 33 public: |
| 32 | 34 |
| 33 BreakTransliterator(const UnicodeString &ID, | |
| 34 UnicodeFilter *adoptedFilter, | |
| 35 BreakIterator *bi, | |
| 36 const UnicodeString &insertion); | |
| 37 /** | 35 /** |
| 38 * Constructs a transliterator. | 36 * Constructs a transliterator. |
| 39 * @param adoptedFilter the filter for this transliterator. | 37 * @param adoptedFilter the filter for this transliterator. |
| 40 */ | 38 */ |
| 41 BreakTransliterator(UnicodeFilter* adoptedFilter = 0); | 39 BreakTransliterator(UnicodeFilter* adoptedFilter = 0); |
| 42 | 40 |
| 43 /** | 41 /** |
| 44 * Destructor. | 42 * Destructor. |
| 45 */ | 43 */ |
| 46 virtual ~BreakTransliterator(); | 44 virtual ~BreakTransliterator(); |
| 47 | 45 |
| 48 /** | 46 /** |
| 49 * Copy constructor. | 47 * Copy constructor. |
| 50 */ | 48 */ |
| 51 BreakTransliterator(const BreakTransliterator&); | 49 BreakTransliterator(const BreakTransliterator&); |
| 52 | 50 |
| 53 /** | 51 /** |
| 54 * Transliterator API. | 52 * Transliterator API. |
| 55 * @return A copy of the object. | 53 * @return A copy of the object. |
| 56 */ | 54 */ |
| 57 virtual Transliterator* clone(void) const; | 55 virtual Transliterator* clone(void) const; |
| 58 | 56 |
| 59 virtual const UnicodeString &getInsertion() const; | 57 virtual const UnicodeString &getInsertion() const; |
| 60 | 58 |
| 61 virtual void setInsertion(const UnicodeString &insertion); | 59 virtual void setInsertion(const UnicodeString &insertion); |
| 62 | 60 |
| 63 /** | 61 /** |
| 64 * Return the break iterator used by this transliterator. | |
| 65 * Caution, this is the live break iterator; it must not be used while | |
| 66 * there is any possibility that this transliterator is using it. | |
| 67 */ | |
| 68 virtual BreakIterator *getBreakIterator(); | |
| 69 | |
| 70 | |
| 71 /** | |
| 72 * ICU "poor man's RTTI", returns a UClassID for the actual class. | 62 * ICU "poor man's RTTI", returns a UClassID for the actual class. |
| 73 */ | 63 */ |
| 74 virtual UClassID getDynamicClassID() const; | 64 virtual UClassID getDynamicClassID() const; |
| 75 | 65 |
| 76 /** | 66 /** |
| 77 * ICU "poor man's RTTI", returns a UClassID for this class. | 67 * ICU "poor man's RTTI", returns a UClassID for this class. |
| 78 */ | 68 */ |
| 79 U_I18N_API static UClassID U_EXPORT2 getStaticClassID(); | 69 U_I18N_API static UClassID U_EXPORT2 getStaticClassID(); |
| 80 | 70 |
| 81 protected: | 71 protected: |
| 82 | 72 |
| 83 /** | 73 /** |
| 84 * Implements {@link Transliterator#handleTransliterate}. | 74 * Implements {@link Transliterator#handleTransliterate}. |
| 85 * @param text the buffer holding transliterated and | 75 * @param text the buffer holding transliterated and |
| 86 * untransliterated text | 76 * untransliterated text |
| 87 * @param offset the start and limit of the text, the position | 77 * @param offset the start and limit of the text, the position |
| 88 * of the cursor, and the start and limit of transliter
ation. | 78 * of the cursor, and the start and limit of transliter
ation. |
| 89 * @param incremental if true, assume more text may be coming after | 79 * @param incremental if true, assume more text may be coming after |
| 90 * pos.contextLimit. Otherwise, assume the text is comp
lete. | 80 * pos.contextLimit. Otherwise, assume the text is comp
lete. |
| 91 */ | 81 */ |
| 92 virtual void handleTransliterate(Replaceable& text, UTransPosition& offset, | 82 virtual void handleTransliterate(Replaceable& text, UTransPosition& offset, |
| 93 UBool isIncremental) const; | 83 UBool isIncremental) const; |
| 94 | 84 |
| 95 private: | 85 private: |
| 96 BreakIterator *bi; | 86 LocalPointer<BreakIterator> cachedBI; |
| 97 UnicodeString fInsertion; | 87 LocalPointer<UVector32> cachedBoundaries; |
| 98 UVector32 *boundaries; | 88 UnicodeString fInsertion; |
| 99 UnicodeString sText; // text from handleTransliterate(). | |
| 100 | 89 |
| 101 static UnicodeString replaceableAsString(Replaceable &r); | 90 static UnicodeString replaceableAsString(Replaceable &r); |
| 102 | 91 |
| 103 /** | 92 /** |
| 104 * Assignment operator. | 93 * Assignment operator. |
| 105 */ | 94 */ |
| 106 BreakTransliterator& operator=(const BreakTransliterator&); | 95 BreakTransliterator& operator=(const BreakTransliterator&); |
| 107 }; | 96 }; |
| 108 | 97 |
| 109 U_NAMESPACE_END | 98 U_NAMESPACE_END |
| 110 | 99 |
| 111 #endif /* #if !UCONFIG_NO_TRANSLITERATION */ | 100 #endif /* #if !UCONFIG_NO_TRANSLITERATION */ |
| 112 | 101 |
| 113 #endif | 102 #endif |
| OLD | NEW |