• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ***************************************************************************
5 *   Copyright (C) 1999-2016 International Business Machines Corporation   *
6 *   and others. All rights reserved.                                      *
7 ***************************************************************************
8 
9 **********************************************************************
10 *   Date        Name        Description
11 *   10/22/99    alan        Creation.
12 *   11/11/99    rgillam     Complete port from Java.
13 **********************************************************************
14 */
15 
16 #ifndef RBBI_H
17 #define RBBI_H
18 
19 #include "unicode/utypes.h"
20 
21 #if U_SHOW_CPLUSPLUS_API
22 
23 /**
24  * \file
25  * \brief C++ API: Rule Based Break Iterator
26  */
27 
28 #if !UCONFIG_NO_BREAK_ITERATION
29 
30 #include "unicode/brkiter.h"
31 #include "unicode/udata.h"
32 #include "unicode/parseerr.h"
33 #include "unicode/schriter.h"
34 
35 struct UCPTrie;
36 
37 U_NAMESPACE_BEGIN
38 
39 /** @internal */
40 class  LanguageBreakEngine;
41 struct RBBIDataHeader;
42 class  RBBIDataWrapper;
43 class  UnhandledEngine;
44 class  UStack;
45 
46 /**
47  *
48  * A subclass of BreakIterator whose behavior is specified using a list of rules.
49  * <p>Instances of this class are most commonly created by the factory methods of
50  *  BreakIterator::createWordInstance(), BreakIterator::createLineInstance(), etc.,
51  *  and then used via the abstract API in class BreakIterator</p>
52  *
53  * <p>See the ICU User Guide for information on Break Iterator Rules.</p>
54  *
55  * <p>This class is not intended to be subclassed.</p>
56  */
57 class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator {
58 
59 private:
60     /**
61      * The UText through which this BreakIterator accesses the text
62      * @internal (private)
63      */
64     UText  fText;
65 
66 #ifndef U_HIDE_INTERNAL_API
67 public:
68 #endif /* U_HIDE_INTERNAL_API */
69     /**
70      * The rule data for this BreakIterator instance.
71      * Not for general use; Public only for testing purposes.
72      * @internal
73      */
74     RBBIDataWrapper    *fData;
75 private:
76 
77     /**
78       * The current  position of the iterator. Pinned, 0 < fPosition <= text.length.
79       * Never has the value UBRK_DONE (-1).
80       */
81     int32_t         fPosition;
82 
83     /**
84       * TODO:
85       */
86     int32_t         fRuleStatusIndex;
87 
88     /**
89      *   Cache of previously determined boundary positions.
90      */
91     class BreakCache;
92     BreakCache         *fBreakCache;
93 
94     /**
95      *  Cache of boundary positions within a region of text that has been
96      *  sub-divided by dictionary based breaking.
97      */
98     class DictionaryCache;
99     DictionaryCache *fDictionaryCache;
100 
101     /**
102      *
103      * If present, UStack of LanguageBreakEngine objects that might handle
104      * dictionary characters. Searched from top to bottom to find an object to
105      * handle a given character.
106      * @internal (private)
107      */
108     UStack              *fLanguageBreakEngines;
109 
110     /**
111      *
112      * If present, the special LanguageBreakEngine used for handling
113      * characters that are in the dictionary set, but not handled by any
114      * LanguageBreakEngine.
115      * @internal (private)
116      */
117     UnhandledEngine     *fUnhandledBreakEngine;
118 
119     /**
120      * Counter for the number of characters encountered with the "dictionary"
121      *   flag set.
122      * @internal (private)
123      */
124     uint32_t            fDictionaryCharCount;
125 
126     /**
127      *   A character iterator that refers to the same text as the UText, above.
128      *   Only included for compatibility with old API, which was based on CharacterIterators.
129      *   Value may be adopted from outside, or one of fSCharIter or fDCharIter, below.
130      */
131     CharacterIterator  *fCharIter;
132 
133     /**
134      *   When the input text is provided by a UnicodeString, this will point to
135      *    a characterIterator that wraps that data.  Needed only for the
136      *    implementation of getText(), a backwards compatibility issue.
137      */
138     StringCharacterIterator fSCharIter;
139 
140     /**
141       * True when iteration has run off the end, and iterator functions should return UBRK_DONE.
142       */
143     UBool           fDone;
144 
145     /**
146      *  Array of look-ahead tentative results.
147      */
148     int32_t *fLookAheadMatches;
149 
150     /**
151      *  A flag to indicate if phrase based breaking is enabled.
152      */
153     UBool fIsPhraseBreaking;
154 
155     //=======================================================================
156     // constructors
157     //=======================================================================
158 
159     /**
160      * Constructor from a flattened set of RBBI data in malloced memory.
161      *             RulesBasedBreakIterators built from a custom set of rules
162      *             are created via this constructor; the rules are compiled
163      *             into memory, then the break iterator is constructed here.
164      *
165      *             The break iterator adopts the memory, and will
166      *             free it when done.
167      * @internal (private)
168      */
169     RuleBasedBreakIterator(RBBIDataHeader* data, UErrorCode &status);
170 
171     /**
172      * This constructor uses the udata interface to create a BreakIterator
173      * whose internal tables live in a memory-mapped file.  "image" is an
174      * ICU UDataMemory handle for the pre-compiled break iterator tables.
175      * @param image handle to the memory image for the break iterator data.
176      *        Ownership of the UDataMemory handle passes to the Break Iterator,
177      *        which will be responsible for closing it when it is no longer needed.
178      * @param status Information on any errors encountered.
179      * @param isPhraseBreaking true if phrase based breaking is required, otherwise false.
180      * @see udata_open
181      * @see #getBinaryRules
182      * @internal (private)
183      */
184     RuleBasedBreakIterator(UDataMemory* image, UBool isPhraseBreaking, UErrorCode &status);
185 
186     /** @internal */
187     friend class RBBIRuleBuilder;
188     /** @internal */
189     friend class BreakIterator;
190 
191 public:
192 
193     /** Default constructor.  Creates an empty shell of an iterator, with no
194      *  rules or text to iterate over.   Object can subsequently be assigned to.
195      *  @stable ICU 2.2
196      */
197     RuleBasedBreakIterator();
198 
199     /**
200      * Copy constructor.  Will produce a break iterator with the same behavior,
201      * and which iterates over the same text, as the one passed in.
202      * @param that The RuleBasedBreakIterator passed to be copied
203      * @stable ICU 2.0
204      */
205     RuleBasedBreakIterator(const RuleBasedBreakIterator& that);
206 
207     /**
208      * Construct a RuleBasedBreakIterator from a set of rules supplied as a string.
209      * @param rules The break rules to be used.
210      * @param parseError  In the event of a syntax error in the rules, provides the location
211      *                    within the rules of the problem.
212      * @param status Information on any errors encountered.
213      * @stable ICU 2.2
214      */
215     RuleBasedBreakIterator( const UnicodeString    &rules,
216                              UParseError           &parseError,
217                              UErrorCode            &status);
218 
219     /**
220      * Construct a RuleBasedBreakIterator from a set of precompiled binary rules.
221      * Binary rules are obtained from RulesBasedBreakIterator::getBinaryRules().
222      * Construction of a break iterator in this way is substantially faster than
223      * construction from source rules.
224      *
225      * Ownership of the storage containing the compiled rules remains with the
226      * caller of this function.  The compiled rules must not be  modified or
227      * deleted during the life of the break iterator.
228      *
229      * The compiled rules are not compatible across different major versions of ICU.
230      * The compiled rules are compatible only between machines with the same
231      * byte ordering (little or big endian) and the same base character set family
232      * (ASCII or EBCDIC).
233      *
234      * @see #getBinaryRules
235      * @param compiledRules A pointer to the compiled break rules to be used.
236      * @param ruleLength The length of the compiled break rules, in bytes.  This
237      *   corresponds to the length value produced by getBinaryRules().
238      * @param status Information on any errors encountered, including invalid
239      *   binary rules.
240      * @stable ICU 4.8
241      */
242     RuleBasedBreakIterator(const uint8_t *compiledRules,
243                            uint32_t       ruleLength,
244                            UErrorCode    &status);
245 
246     /**
247      * This constructor uses the udata interface to create a BreakIterator
248      * whose internal tables live in a memory-mapped file.  "image" is an
249      * ICU UDataMemory handle for the pre-compiled break iterator tables.
250      * @param image handle to the memory image for the break iterator data.
251      *        Ownership of the UDataMemory handle passes to the Break Iterator,
252      *        which will be responsible for closing it when it is no longer needed.
253      * @param status Information on any errors encountered.
254      * @see udata_open
255      * @see #getBinaryRules
256      * @stable ICU 2.8
257      */
258     RuleBasedBreakIterator(UDataMemory* image, UErrorCode &status);
259 
260     /**
261      * Destructor
262      *  @stable ICU 2.0
263      */
264     virtual ~RuleBasedBreakIterator();
265 
266     /**
267      * Assignment operator.  Sets this iterator to have the same behavior,
268      * and iterate over the same text, as the one passed in.
269      * @param that The RuleBasedBreakItertor passed in
270      * @return the newly created RuleBasedBreakIterator
271      *  @stable ICU 2.0
272      */
273     RuleBasedBreakIterator& operator=(const RuleBasedBreakIterator& that);
274 
275     /**
276      * Equality operator.  Returns true if both BreakIterators are of the
277      * same class, have the same behavior, and iterate over the same text.
278      * @param that The BreakIterator to be compared for equality
279      * @return true if both BreakIterators are of the
280      * same class, have the same behavior, and iterate over the same text.
281      *  @stable ICU 2.0
282      */
283     virtual bool operator==(const BreakIterator& that) const override;
284 
285     /**
286      * Not-equal operator.  If operator== returns true, this returns false,
287      * and vice versa.
288      * @param that The BreakIterator to be compared for inequality
289      * @return true if both BreakIterators are not same.
290      *  @stable ICU 2.0
291      */
292     inline bool operator!=(const BreakIterator& that) const;
293 
294     /**
295      * Returns a newly-constructed RuleBasedBreakIterator with the same
296      * behavior, and iterating over the same text, as this one.
297      * Differs from the copy constructor in that it is polymorphic, and
298      * will correctly clone (copy) a derived class.
299      * clone() is thread safe.  Multiple threads may simultaneously
300      * clone the same source break iterator.
301      * @return a newly-constructed RuleBasedBreakIterator
302      * @stable ICU 2.0
303      */
304     virtual RuleBasedBreakIterator* clone() const override;
305 
306     /**
307      * Compute a hash code for this BreakIterator
308      * @return A hash code
309      *  @stable ICU 2.0
310      */
311     virtual int32_t hashCode(void) const;
312 
313     /**
314      * Returns the description used to create this iterator
315      * @return the description used to create this iterator
316      *  @stable ICU 2.0
317      */
318     virtual const UnicodeString& getRules(void) const;
319 
320     //=======================================================================
321     // BreakIterator overrides
322     //=======================================================================
323 
324     /**
325      * <p>
326      * Return a CharacterIterator over the text being analyzed.
327      * The returned character iterator is owned by the break iterator, and must
328      * not be deleted by the caller.  Repeated calls to this function may
329      * return the same CharacterIterator.
330      * </p>
331      * <p>
332      * The returned character iterator must not be used concurrently with
333      * the break iterator.  If concurrent operation is needed, clone the
334      * returned character iterator first and operate on the clone.
335      * </p>
336      * <p>
337      * When the break iterator is operating on text supplied via a UText,
338      * this function will fail.  Lacking any way to signal failures, it
339      * returns an CharacterIterator containing no text.
340      * The function getUText() provides similar functionality,
341      * is reliable, and is more efficient.
342      * </p>
343      *
344      * TODO:  deprecate this function?
345      *
346      * @return An iterator over the text being analyzed.
347      * @stable ICU 2.0
348      */
349     virtual  CharacterIterator& getText(void) const override;
350 
351 
352     /**
353       *  Get a UText for the text being analyzed.
354       *  The returned UText is a shallow clone of the UText used internally
355       *  by the break iterator implementation.  It can safely be used to
356       *  access the text without impacting any break iterator operations,
357       *  but the underlying text itself must not be altered.
358       *
359       * @param fillIn A UText to be filled in.  If NULL, a new UText will be
360       *           allocated to hold the result.
361       * @param status receives any error codes.
362       * @return   The current UText for this break iterator.  If an input
363       *           UText was provided, it will always be returned.
364       * @stable ICU 3.4
365       */
366      virtual UText *getUText(UText *fillIn, UErrorCode &status) const override;
367 
368     /**
369      * Set the iterator to analyze a new piece of text.  This function resets
370      * the current iteration position to the beginning of the text.
371      * @param newText An iterator over the text to analyze.  The BreakIterator
372      * takes ownership of the character iterator.  The caller MUST NOT delete it!
373      *  @stable ICU 2.0
374      */
375     virtual void adoptText(CharacterIterator* newText) override;
376 
377     /**
378      * Set the iterator to analyze a new piece of text.  This function resets
379      * the current iteration position to the beginning of the text.
380      *
381      * The BreakIterator will retain a reference to the supplied string.
382      * The caller must not modify or delete the text while the BreakIterator
383      * retains the reference.
384      *
385      * @param newText The text to analyze.
386      *  @stable ICU 2.0
387      */
388     virtual void setText(const UnicodeString& newText) override;
389 
390     /**
391      * Reset the break iterator to operate over the text represented by
392      * the UText.  The iterator position is reset to the start.
393      *
394      * This function makes a shallow clone of the supplied UText.  This means
395      * that the caller is free to immediately close or otherwise reuse the
396      * Utext that was passed as a parameter, but that the underlying text itself
397      * must not be altered while being referenced by the break iterator.
398      *
399      * @param text    The UText used to change the text.
400      * @param status  Receives any error codes.
401      * @stable ICU 3.4
402      */
403     virtual void  setText(UText *text, UErrorCode &status) override;
404 
405     /**
406      * Sets the current iteration position to the beginning of the text, position zero.
407      * @return The offset of the beginning of the text, zero.
408      *  @stable ICU 2.0
409      */
410     virtual int32_t first(void) override;
411 
412     /**
413      * Sets the current iteration position to the end of the text.
414      * @return The text's past-the-end offset.
415      *  @stable ICU 2.0
416      */
417     virtual int32_t last(void) override;
418 
419     /**
420      * Advances the iterator either forward or backward the specified number of steps.
421      * Negative values move backward, and positive values move forward.  This is
422      * equivalent to repeatedly calling next() or previous().
423      * @param n The number of steps to move.  The sign indicates the direction
424      * (negative is backwards, and positive is forwards).
425      * @return The character offset of the boundary position n boundaries away from
426      * the current one.
427      *  @stable ICU 2.0
428      */
429     virtual int32_t next(int32_t n) override;
430 
431     /**
432      * Advances the iterator to the next boundary position.
433      * @return The position of the first boundary after this one.
434      *  @stable ICU 2.0
435      */
436     virtual int32_t next(void) override;
437 
438     /**
439      * Moves the iterator backwards, to the last boundary preceding this one.
440      * @return The position of the last boundary position preceding this one.
441      *  @stable ICU 2.0
442      */
443     virtual int32_t previous(void) override;
444 
445     /**
446      * Sets the iterator to refer to the first boundary position following
447      * the specified position.
448      * @param offset The position from which to begin searching for a break position.
449      * @return The position of the first break after the current position.
450      *  @stable ICU 2.0
451      */
452     virtual int32_t following(int32_t offset) override;
453 
454     /**
455      * Sets the iterator to refer to the last boundary position before the
456      * specified position.
457      * @param offset The position to begin searching for a break from.
458      * @return The position of the last boundary before the starting position.
459      *  @stable ICU 2.0
460      */
461     virtual int32_t preceding(int32_t offset) override;
462 
463     /**
464      * Returns true if the specified position is a boundary position.  As a side
465      * effect, leaves the iterator pointing to the first boundary position at
466      * or after "offset".
467      * @param offset the offset to check.
468      * @return True if "offset" is a boundary position.
469      *  @stable ICU 2.0
470      */
471     virtual UBool isBoundary(int32_t offset) override;
472 
473     /**
474      * Returns the current iteration position. Note that UBRK_DONE is never
475      * returned from this function; if iteration has run to the end of a
476      * string, current() will return the length of the string while
477      * next() will return UBRK_DONE).
478      * @return The current iteration position.
479      * @stable ICU 2.0
480      */
481     virtual int32_t current(void) const override;
482 
483 
484     /**
485      * Return the status tag from the break rule that determined the boundary at
486      * the current iteration position.  For break rules that do not specify a
487      * status, a default value of 0 is returned.  If more than one break rule
488      * would cause a boundary to be located at some position in the text,
489      * the numerically largest of the applicable status values is returned.
490      * <p>
491      * Of the standard types of ICU break iterators, only word break and
492      * line break provide status values.  The values are defined in
493      * the header file ubrk.h.  For Word breaks, the status allows distinguishing between words
494      * that contain alphabetic letters, "words" that appear to be numbers,
495      * punctuation and spaces, words containing ideographic characters, and
496      * more.  For Line Break, the status distinguishes between hard (mandatory) breaks
497      * and soft (potential) break positions.
498      * <p>
499      * <code>getRuleStatus()</code> can be called after obtaining a boundary
500      * position from <code>next()</code>, <code>previous()</code>, or
501      * any other break iterator functions that returns a boundary position.
502      * <p>
503      * Note that <code>getRuleStatus()</code> returns the value corresponding to
504      * <code>current()</code> index even after <code>next()</code> has returned DONE.
505      * <p>
506      * When creating custom break rules, one is free to define whatever
507      * status values may be convenient for the application.
508      * <p>
509      * @return the status from the break rule that determined the boundary
510      * at the current iteration position.
511      *
512      * @see UWordBreak
513      * @stable ICU 2.2
514      */
515     virtual int32_t getRuleStatus() const override;
516 
517    /**
518     * Get the status (tag) values from the break rule(s) that determined the boundary
519     * at the current iteration position.
520     * <p>
521     * The returned status value(s) are stored into an array provided by the caller.
522     * The values are stored in sorted (ascending) order.
523     * If the capacity of the output array is insufficient to hold the data,
524     *  the output will be truncated to the available length, and a
525     *  U_BUFFER_OVERFLOW_ERROR will be signaled.
526     *
527     * @param fillInVec an array to be filled in with the status values.
528     * @param capacity  the length of the supplied vector.  A length of zero causes
529     *                  the function to return the number of status values, in the
530     *                  normal way, without attempting to store any values.
531     * @param status    receives error codes.
532     * @return          The number of rule status values from the rules that determined
533     *                  the boundary at the current iteration position.
534     *                  In the event of a U_BUFFER_OVERFLOW_ERROR, the return value
535     *                  is the total number of status values that were available,
536     *                  not the reduced number that were actually returned.
537     * @see getRuleStatus
538     * @stable ICU 3.0
539     */
540     virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status) override;
541 
542     /**
543      * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.
544      * This method is to implement a simple version of RTTI, since not all
545      * C++ compilers support genuine RTTI.  Polymorphic operator==() and
546      * clone() methods call this method.
547      *
548      * @return          The class ID for this object. All objects of a
549      *                  given class have the same class ID.  Objects of
550      *                  other classes have different class IDs.
551      * @stable ICU 2.0
552      */
553     virtual UClassID getDynamicClassID(void) const override;
554 
555     /**
556      * Returns the class ID for this class.  This is useful only for
557      * comparing to a return value from getDynamicClassID().  For example:
558      *
559      *      Base* polymorphic_pointer = createPolymorphicObject();
560      *      if (polymorphic_pointer->getDynamicClassID() ==
561      *          Derived::getStaticClassID()) ...
562      *
563      * @return          The class ID for all objects of this class.
564      * @stable ICU 2.0
565      */
566     static UClassID U_EXPORT2 getStaticClassID(void);
567 
568 #ifndef U_FORCE_HIDE_DEPRECATED_API
569     /**
570      * Deprecated functionality. Use clone() instead.
571      *
572      * Create a clone (copy) of this break iterator in memory provided
573      *  by the caller.  The idea is to increase performance by avoiding
574      *  a storage allocation.  Use of this function is NOT RECOMMENDED.
575      *  Performance gains are minimal, and correct buffer management is
576      *  tricky.  Use clone() instead.
577      *
578      * @param stackBuffer  The pointer to the memory into which the cloned object
579      *                     should be placed.  If NULL,  allocate heap memory
580      *                     for the cloned object.
581      * @param BufferSize   The size of the buffer.  If zero, return the required
582      *                     buffer size, but do not clone the object.  If the
583      *                     size was too small (but not zero), allocate heap
584      *                     storage for the cloned object.
585      *
586      * @param status       Error status.  U_SAFECLONE_ALLOCATED_WARNING will be
587      *                     returned if the provided buffer was too small, and
588      *                     the clone was therefore put on the heap.
589      *
590      * @return  Pointer to the clone object.  This may differ from the stackBuffer
591      *          address if the byte alignment of the stack buffer was not suitable
592      *          or if the stackBuffer was too small to hold the clone.
593      * @deprecated ICU 52. Use clone() instead.
594      */
595     virtual RuleBasedBreakIterator *createBufferClone(void *stackBuffer,
596                                                       int32_t &BufferSize,
597                                                       UErrorCode &status) override;
598 #endif  // U_FORCE_HIDE_DEPRECATED_API
599 
600     /**
601      * Return the binary form of compiled break rules,
602      * which can then be used to create a new break iterator at some
603      * time in the future.  Creating a break iterator from pre-compiled rules
604      * is much faster than building one from the source form of the
605      * break rules.
606      *
607      * The binary data can only be used with the same version of ICU
608      *  and on the same platform type (processor endian-ness)
609      *
610      * @param length Returns the length of the binary data.  (Out parameter.)
611      *
612      * @return   A pointer to the binary (compiled) rule data.  The storage
613      *           belongs to the RulesBasedBreakIterator object, not the
614      *           caller, and must not be modified or deleted.
615      * @stable ICU 4.8
616      */
617     virtual const uint8_t *getBinaryRules(uint32_t &length);
618 
619     /**
620      *  Set the subject text string upon which the break iterator is operating
621      *  without changing any other aspect of the matching state.
622      *  The new and previous text strings must have the same content.
623      *
624      *  This function is intended for use in environments where ICU is operating on
625      *  strings that may move around in memory.  It provides a mechanism for notifying
626      *  ICU that the string has been relocated, and providing a new UText to access the
627      *  string in its new position.
628      *
629      *  Note that the break iterator implementation never copies the underlying text
630      *  of a string being processed, but always operates directly on the original text
631      *  provided by the user. Refreshing simply drops the references to the old text
632      *  and replaces them with references to the new.
633      *
634      *  Caution:  this function is normally used only by very specialized,
635      *  system-level code.  One example use case is with garbage collection that moves
636      *  the text in memory.
637      *
638      * @param input      The new (moved) text string.
639      * @param status     Receives errors detected by this function.
640      * @return           *this
641      *
642      * @stable ICU 49
643      */
644     virtual RuleBasedBreakIterator &refreshInputText(UText *input, UErrorCode &status) override;
645 
646 
647 private:
648     //=======================================================================
649     // implementation
650     //=======================================================================
651     /**
652       * Common initialization function, used by constructors and bufferClone.
653       * @internal (private)
654       */
655     void init(UErrorCode &status);
656 
657     /**
658      * Iterate backwards from an arbitrary position in the input text using the
659      * synthesized Safe Reverse rules.
660      * This locates a "Safe Position" from which the forward break rules
661      * will operate correctly. A Safe Position is not necessarily a boundary itself.
662      *
663      * @param fromPosition the position in the input text to begin the iteration.
664      * @internal (private)
665      */
666     int32_t handleSafePrevious(int32_t fromPosition);
667 
668     /**
669      * Find a rule-based boundary by running the state machine.
670      * Input
671      *    fPosition, the position in the text to begin from.
672      * Output
673      *    fPosition:           the boundary following the starting position.
674      *    fDictionaryCharCount the number of dictionary characters encountered.
675      *                         If > 0, the segment will be further subdivided
676      *    fRuleStatusIndex     Info from the state table indicating which rules caused the boundary.
677      *
678      * @internal (private)
679      */
680     int32_t handleNext();
681 
682     /*
683      * Templatized version of handleNext() and handleSafePrevious().
684      *
685      * There will be exactly four instantiations, two each for 8 and 16 bit tables,
686      * two each for 8 and 16 bit trie.
687      * Having separate instantiations for the table types keeps conditional tests of
688      * the table type out of the inner loops, at the expense of replicated code.
689      *
690      * The template parameter for the Trie access function is a value, not a type.
691      * Doing it this way, the compiler will inline the Trie function in the
692      * expanded functions. (Both the 8 and 16 bit access functions have the same type
693      * signature)
694      */
695 
696     typedef uint16_t (*PTrieFunc)(const UCPTrie *, UChar32);
697 
698     template<typename RowType, PTrieFunc trieFunc>
699     int32_t handleSafePrevious(int32_t fromPosition);
700 
701     template<typename RowType, PTrieFunc trieFunc>
702     int32_t handleNext();
703 
704 
705     /**
706      * This function returns the appropriate LanguageBreakEngine for a
707      * given character c.
708      * @param c         A character in the dictionary set
709      * @internal (private)
710      */
711     const LanguageBreakEngine *getLanguageBreakEngine(UChar32 c);
712 
713   public:
714 #ifndef U_HIDE_INTERNAL_API
715     /**
716      *   Debugging function only.
717      *   @internal
718      */
719      void dumpCache();
720 
721     /**
722      * Debugging function only.
723      * @internal
724      */
725     void dumpTables();
726 #endif  /* U_HIDE_INTERNAL_API */
727 };
728 
729 //------------------------------------------------------------------------------
730 //
731 //   Inline Functions Definitions ...
732 //
733 //------------------------------------------------------------------------------
734 
735 inline bool RuleBasedBreakIterator::operator!=(const BreakIterator& that) const {
736     return !operator==(that);
737 }
738 
739 U_NAMESPACE_END
740 
741 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
742 
743 #endif /* U_SHOW_CPLUSPLUS_API */
744 
745 #endif
746