1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/brktrans.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,113 @@ 1.4 +/* 1.5 +********************************************************************** 1.6 +* Copyright (C) 2008-2009, International Business Machines 1.7 +* Corporation and others. All Rights Reserved. 1.8 +********************************************************************** 1.9 +* Date Name Description 1.10 +* 05/11/2008 Andy Heninger Ported from Java 1.11 +********************************************************************** 1.12 +*/ 1.13 +#ifndef BRKTRANS_H 1.14 +#define BRKTRANS_H 1.15 + 1.16 +#include "unicode/utypes.h" 1.17 + 1.18 +#if !UCONFIG_NO_TRANSLITERATION && !UCONFIG_NO_BREAK_ITERATION 1.19 + 1.20 +#include "unicode/translit.h" 1.21 + 1.22 + 1.23 +U_NAMESPACE_BEGIN 1.24 + 1.25 +class UVector32; 1.26 + 1.27 +/** 1.28 + * A transliterator that pInserts the specified characters at word breaks. 1.29 + * To restrict it to particular characters, use a filter. 1.30 + * TODO: this is an internal class, and only temporary. 1.31 + * Remove it once we have \b notation in Transliterator. 1.32 + */ 1.33 +class BreakTransliterator : public Transliterator { 1.34 +public: 1.35 + 1.36 + BreakTransliterator(const UnicodeString &ID, 1.37 + UnicodeFilter *adoptedFilter, 1.38 + BreakIterator *bi, 1.39 + const UnicodeString &insertion); 1.40 + /** 1.41 + * Constructs a transliterator. 1.42 + * @param adoptedFilter the filter for this transliterator. 1.43 + */ 1.44 + BreakTransliterator(UnicodeFilter* adoptedFilter = 0); 1.45 + 1.46 + /** 1.47 + * Destructor. 1.48 + */ 1.49 + virtual ~BreakTransliterator(); 1.50 + 1.51 + /** 1.52 + * Copy constructor. 1.53 + */ 1.54 + BreakTransliterator(const BreakTransliterator&); 1.55 + 1.56 + /** 1.57 + * Transliterator API. 1.58 + * @return A copy of the object. 1.59 + */ 1.60 + virtual Transliterator* clone(void) const; 1.61 + 1.62 + virtual const UnicodeString &getInsertion() const; 1.63 + 1.64 + virtual void setInsertion(const UnicodeString &insertion); 1.65 + 1.66 + /** 1.67 + * Return the break iterator used by this transliterator. 1.68 + * Caution, this is the live break iterator; it must not be used while 1.69 + * there is any possibility that this transliterator is using it. 1.70 + */ 1.71 + virtual BreakIterator *getBreakIterator(); 1.72 + 1.73 + 1.74 + /** 1.75 + * ICU "poor man's RTTI", returns a UClassID for the actual class. 1.76 + */ 1.77 + virtual UClassID getDynamicClassID() const; 1.78 + 1.79 + /** 1.80 + * ICU "poor man's RTTI", returns a UClassID for this class. 1.81 + */ 1.82 + U_I18N_API static UClassID U_EXPORT2 getStaticClassID(); 1.83 + 1.84 + protected: 1.85 + 1.86 + /** 1.87 + * Implements {@link Transliterator#handleTransliterate}. 1.88 + * @param text the buffer holding transliterated and 1.89 + * untransliterated text 1.90 + * @param offset the start and limit of the text, the position 1.91 + * of the cursor, and the start and limit of transliteration. 1.92 + * @param incremental if true, assume more text may be coming after 1.93 + * pos.contextLimit. Otherwise, assume the text is complete. 1.94 + */ 1.95 + virtual void handleTransliterate(Replaceable& text, UTransPosition& offset, 1.96 + UBool isIncremental) const; 1.97 + 1.98 + private: 1.99 + BreakIterator *bi; 1.100 + UnicodeString fInsertion; 1.101 + UVector32 *boundaries; 1.102 + UnicodeString sText; // text from handleTransliterate(). 1.103 + 1.104 + static UnicodeString replaceableAsString(Replaceable &r); 1.105 + 1.106 + /** 1.107 + * Assignment operator. 1.108 + */ 1.109 + BreakTransliterator& operator=(const BreakTransliterator&); 1.110 +}; 1.111 + 1.112 +U_NAMESPACE_END 1.113 + 1.114 +#endif /* #if !UCONFIG_NO_TRANSLITERATION */ 1.115 + 1.116 +#endif