michael@0: /* michael@0: ********************************************************************** michael@0: * Copyright (C) 2008-2009, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ********************************************************************** michael@0: * Date Name Description michael@0: * 05/11/2008 Andy Heninger Ported from Java michael@0: ********************************************************************** michael@0: */ michael@0: #ifndef BRKTRANS_H michael@0: #define BRKTRANS_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_TRANSLITERATION && !UCONFIG_NO_BREAK_ITERATION michael@0: michael@0: #include "unicode/translit.h" michael@0: michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: class UVector32; michael@0: michael@0: /** michael@0: * A transliterator that pInserts the specified characters at word breaks. michael@0: * To restrict it to particular characters, use a filter. michael@0: * TODO: this is an internal class, and only temporary. michael@0: * Remove it once we have \b notation in Transliterator. michael@0: */ michael@0: class BreakTransliterator : public Transliterator { michael@0: public: michael@0: michael@0: BreakTransliterator(const UnicodeString &ID, michael@0: UnicodeFilter *adoptedFilter, michael@0: BreakIterator *bi, michael@0: const UnicodeString &insertion); michael@0: /** michael@0: * Constructs a transliterator. michael@0: * @param adoptedFilter the filter for this transliterator. michael@0: */ michael@0: BreakTransliterator(UnicodeFilter* adoptedFilter = 0); michael@0: michael@0: /** michael@0: * Destructor. michael@0: */ michael@0: virtual ~BreakTransliterator(); michael@0: michael@0: /** michael@0: * Copy constructor. michael@0: */ michael@0: BreakTransliterator(const BreakTransliterator&); michael@0: michael@0: /** michael@0: * Transliterator API. michael@0: * @return A copy of the object. michael@0: */ michael@0: virtual Transliterator* clone(void) const; michael@0: michael@0: virtual const UnicodeString &getInsertion() const; michael@0: michael@0: virtual void setInsertion(const UnicodeString &insertion); michael@0: michael@0: /** michael@0: * Return the break iterator used by this transliterator. michael@0: * Caution, this is the live break iterator; it must not be used while michael@0: * there is any possibility that this transliterator is using it. michael@0: */ michael@0: virtual BreakIterator *getBreakIterator(); michael@0: michael@0: michael@0: /** michael@0: * ICU "poor man's RTTI", returns a UClassID for the actual class. michael@0: */ michael@0: virtual UClassID getDynamicClassID() const; michael@0: michael@0: /** michael@0: * ICU "poor man's RTTI", returns a UClassID for this class. michael@0: */ michael@0: U_I18N_API static UClassID U_EXPORT2 getStaticClassID(); michael@0: michael@0: protected: michael@0: michael@0: /** michael@0: * Implements {@link Transliterator#handleTransliterate}. michael@0: * @param text the buffer holding transliterated and michael@0: * untransliterated text michael@0: * @param offset the start and limit of the text, the position michael@0: * of the cursor, and the start and limit of transliteration. michael@0: * @param incremental if true, assume more text may be coming after michael@0: * pos.contextLimit. Otherwise, assume the text is complete. michael@0: */ michael@0: virtual void handleTransliterate(Replaceable& text, UTransPosition& offset, michael@0: UBool isIncremental) const; michael@0: michael@0: private: michael@0: BreakIterator *bi; michael@0: UnicodeString fInsertion; michael@0: UVector32 *boundaries; michael@0: UnicodeString sText; // text from handleTransliterate(). michael@0: michael@0: static UnicodeString replaceableAsString(Replaceable &r); michael@0: michael@0: /** michael@0: * Assignment operator. michael@0: */ michael@0: BreakTransliterator& operator=(const BreakTransliterator&); michael@0: }; michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* #if !UCONFIG_NO_TRANSLITERATION */ michael@0: michael@0: #endif