ICU 61.1  61.1
rbbi.h
Go to the documentation of this file.
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 
26 #if !UCONFIG_NO_BREAK_ITERATION
27 
28 #include "unicode/brkiter.h"
29 #include "unicode/udata.h"
30 #include "unicode/parseerr.h"
31 #include "unicode/schriter.h"
32 
34 
36 class LanguageBreakEngine;
37 struct RBBIDataHeader;
38 class RBBIDataWrapper;
39 class UnhandledEngine;
40 class UStack;
41 
54 
55 private:
60  UText fText;
61 
62 #ifndef U_HIDE_INTERNAL_API
63 public:
64 #endif /* U_HIDE_INTERNAL_API */
65 
70  RBBIDataWrapper *fData;
71 private:
72 
84  int32_t fPosition;
85 
89  int32_t fRuleStatusIndex;
90 
94  class BreakCache;
95  BreakCache *fBreakCache;
96 
101  class DictionaryCache;
102  DictionaryCache *fDictionaryCache;
103 
111  UStack *fLanguageBreakEngines;
112 
120  UnhandledEngine *fUnhandledBreakEngine;
121 
127  uint32_t fDictionaryCharCount;
128 
134  CharacterIterator *fCharIter;
135 
141  StringCharacterIterator fSCharIter;
142 
146  UBool fDone;
147 
148  //=======================================================================
149  // constructors
150  //=======================================================================
151 
162  RuleBasedBreakIterator(RBBIDataHeader* data, UErrorCode &status);
163 
165  friend class RBBIRuleBuilder;
167  friend class BreakIterator;
168 
169 public:
170 
176 
184 
194  UParseError &parseError,
195  UErrorCode &status);
196 
220  RuleBasedBreakIterator(const uint8_t *compiledRules,
221  uint32_t ruleLength,
222  UErrorCode &status);
223 
237 
242  virtual ~RuleBasedBreakIterator();
243 
252 
261  virtual UBool operator==(const BreakIterator& that) const;
262 
270  UBool operator!=(const BreakIterator& that) const;
271 
282  virtual BreakIterator* clone() const;
283 
289  virtual int32_t hashCode(void) const;
290 
296  virtual const UnicodeString& getRules(void) const;
297 
298  //=======================================================================
299  // BreakIterator overrides
300  //=======================================================================
301 
327  virtual CharacterIterator& getText(void) const;
328 
329 
344  virtual UText *getUText(UText *fillIn, UErrorCode &status) const;
345 
353  virtual void adoptText(CharacterIterator* newText);
354 
366  virtual void setText(const UnicodeString& newText);
367 
381  virtual void setText(UText *text, UErrorCode &status);
382 
388  virtual int32_t first(void);
389 
395  virtual int32_t last(void);
396 
407  virtual int32_t next(int32_t n);
408 
414  virtual int32_t next(void);
415 
421  virtual int32_t previous(void);
422 
430  virtual int32_t following(int32_t offset);
431 
439  virtual int32_t preceding(int32_t offset);
440 
449  virtual UBool isBoundary(int32_t offset);
450 
459  virtual int32_t current(void) const;
460 
461 
493  virtual int32_t getRuleStatus() const;
494 
518  virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status);
519 
531  virtual UClassID getDynamicClassID(void) const;
532 
544  static UClassID U_EXPORT2 getStaticClassID(void);
545 
572  virtual BreakIterator * createBufferClone(void *stackBuffer,
573  int32_t &BufferSize,
574  UErrorCode &status);
575 
576 
594  virtual const uint8_t *getBinaryRules(uint32_t &length);
595 
621  virtual RuleBasedBreakIterator &refreshInputText(UText *input, UErrorCode &status);
622 
623 
624 private:
625  //=======================================================================
626  // implementation
627  //=======================================================================
633  void reset(void);
634 
639  void init(UErrorCode &status);
640 
649  int32_t handlePrevious(int32_t fromPosition);
650 
663  int32_t handleNext();
664 
665 
672  const LanguageBreakEngine *getLanguageBreakEngine(UChar32 c);
673 
674  public:
675 #ifndef U_HIDE_INTERNAL_API
676 
680  void dumpCache();
681 
686  void dumpTables();
687 
688 #endif /* U_HIDE_INTERNAL_API */
689 };
690 
691 //------------------------------------------------------------------------------
692 //
693 // Inline Functions Definitions ...
694 //
695 //------------------------------------------------------------------------------
696 
698  return !operator==(that);
699 }
700 
702 
703 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
704 
705 #endif
C++ API: Break Iterator.
BreakIterator & operator=(const BreakIterator &other)
RBBIDataWrapper * fData
The rule data for this BreakIterator instance.
Definition: rbbi.h:70
virtual int32_t next(void)=0
Advance the iterator to the boundary following the current boundary.
virtual UBool isBoundary(int32_t offset)=0
Return true if the specified position is a boundary position.
virtual void adoptText(CharacterIterator *it)=0
Change the text over which this operates.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:93
virtual CharacterIterator & getText(void) const =0
Return a CharacterIterator over the text being analyzed.
virtual UText * getUText(UText *fillIn, UErrorCode &status) const =0
Get a UText for the text being analyzed.
virtual int32_t first(void)=0
Sets the current iteration position to the beginning of the text, position zero.
virtual int32_t following(int32_t offset)=0
Advance the iterator to the first boundary following the specified offset.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:358
C++ API: String Character Iterator.
A concrete subclass of CharacterIterator that iterates over the characters (code units or code points...
Definition: schriter.h:45
The BreakIterator class implements methods for finding the location of boundaries in text...
Definition: brkiter.h:102
virtual int32_t last(void)=0
Set the iterator position to the index immediately BEYOND the last character in the text being scanne...
virtual int32_t current(void) const =0
Return character index of the current iterator position within the text.
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:400
virtual UBool operator==(const BreakIterator &) const =0
Return true if another object is semantically equal to this one.
virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status)
For RuleBasedBreakIterators, get the status (tag) values from the break rule(s) that determined the b...
C API: Data loading interface.
struct UDataMemory UDataMemory
Forward declaration of the data memory type.
Definition: udata.h:158
virtual int32_t previous(void)=0
Set the iterator position to the boundary preceding the current boundary.
virtual int32_t getRuleStatus() const
For RuleBasedBreakIterators, return the status tag from the break rule that determined the boundary a...
virtual UClassID getDynamicClassID(void) const =0
Return a polymorphic class ID for this object.
virtual void setText(const UnicodeString &text)=0
Change the text over which this operates.
virtual BreakIterator & refreshInputText(UText *input, UErrorCode &status)=0
Set the subject text string upon which the break iterator is operating without changing any other asp...
virtual BreakIterator * clone(void) const =0
Return a polymorphic copy of this object.
UBool operator!=(const BreakIterator &rhs) const
Returns the complement of the result of operator==.
Definition: brkiter.h:131
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
C API: Parse Error Information.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
virtual BreakIterator * createBufferClone(void *stackBuffer, int32_t &BufferSize, UErrorCode &status)=0
Deprecated functionality.
UText struct.
Definition: utext.h:1345
A subclass of BreakIterator whose behavior is specified using a list of rules.
Definition: rbbi.h:53
virtual int32_t preceding(int32_t offset)=0
Set the iterator position to the first boundary preceding the specified offset.
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
Basic definitions for ICU, for both C and C++ APIs.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:359
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:286
UBool operator!=(const BreakIterator &that) const
Not-equal operator.
Definition: rbbi.h:697
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236