Coverage Report

Created: 2025-06-24 06:43

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