tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

brktrans.h (3063B)


      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 
     15 #include "unicode/utypes.h"
     16 
     17 #if !UCONFIG_NO_TRANSLITERATION && !UCONFIG_NO_BREAK_ITERATION
     18 
     19 #include "unicode/translit.h"
     20 
     21 #include "unicode/localpointer.h"
     22 
     23 
     24 U_NAMESPACE_BEGIN
     25 
     26 class UVector32;
     27 
     28 /**
     29 * A transliterator that pInserts the specified characters at word breaks.
     30 * To restrict it to particular characters, use a filter.
     31 * TODO: this is an internal class, and only temporary. 
     32 * Remove it once we have \b notation in Transliterator.
     33 */
     34 class BreakTransliterator : public Transliterator {
     35 public:
     36 
     37    /**
     38     * Constructs a transliterator.
     39     * @param adoptedFilter    the filter for this transliterator.
     40     */
     41    BreakTransliterator(UnicodeFilter* adoptedFilter = nullptr);
     42 
     43    /**
     44     * Destructor.
     45     */
     46    virtual ~BreakTransliterator();
     47 
     48    /**
     49     * Copy constructor.
     50     */
     51    BreakTransliterator(const BreakTransliterator&);
     52 
     53    /**
     54     * Transliterator API.
     55     * @return    A copy of the object.
     56     */
     57    virtual BreakTransliterator* clone() const override;
     58 
     59    virtual const UnicodeString &getInsertion() const;
     60 
     61    virtual void setInsertion(const UnicodeString &insertion);
     62 
     63    /**
     64     * ICU "poor man's RTTI", returns a UClassID for the actual class.
     65     */
     66    virtual UClassID getDynamicClassID() const override;
     67 
     68    /**
     69     * ICU "poor man's RTTI", returns a UClassID for this class.
     70     */
     71    U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
     72 
     73 protected:
     74 
     75    /**
     76     * Implements {@link Transliterator#handleTransliterate}.
     77     * @param text          the buffer holding transliterated and
     78     *                      untransliterated text
     79     * @param offset        the start and limit of the text, the position
     80     *                      of the cursor, and the start and limit of transliteration.
     81     * @param incremental   if true, assume more text may be coming after
     82     *                      pos.contextLimit. Otherwise, assume the text is complete.
     83     */
     84    virtual void handleTransliterate(Replaceable& text, UTransPosition& offset,
     85                                     UBool isIncremental) const override;
     86 
     87 private:
     88     LocalPointer<BreakIterator> cachedBI;
     89     LocalPointer<UVector32>     cachedBoundaries;
     90     UnicodeString               fInsertion;
     91 
     92     static UnicodeString replaceableAsString(Replaceable &r);
     93 
     94    /**
     95     * Assignment operator.
     96     */
     97    BreakTransliterator& operator=(const BreakTransliterator&);
     98 };
     99 
    100 U_NAMESPACE_END
    101 
    102 #endif /* #if !UCONFIG_NO_TRANSLITERATION */
    103 
    104 #endif