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