intl/icu/source/i18n/brktrans.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial