ICU 60.2 60.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

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 #include "unicode/uchriter.h"
33
34 U_NAMESPACE_BEGIN
35
37 class LanguageBreakEngine;
38 struct RBBIDataHeader;
39 class RBBIDataWrapper;
40 class UnhandledEngine;
41 class UStack;
42
54 class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator {
55
56 private:
61 UText *fText;
62
68 CharacterIterator *fCharIter;
69
75 StringCharacterIterator *fSCharIter;
76
82 UCharCharacterIterator *fDCharIter;
83
88 RBBIDataWrapper *fData;
89
101 int32_t fPosition;
102
106 int32_t fRuleStatusIndex;
107
111 UBool fDone;
112
116 public: // TODO: debug, return to private.
117 class BreakCache;
118 BreakCache *fBreakCache;
119 private:
125 uint32_t fDictionaryCharCount;
126
131 class DictionaryCache;
132 DictionaryCache *fDictionaryCache;
133
141 UStack *fLanguageBreakEngines;
142
150 UnhandledEngine *fUnhandledBreakEngine;
151
157 int32_t fBreakType;
158
159 //=======================================================================
160 // constructors
161 //=======================================================================
162
173 RuleBasedBreakIterator(RBBIDataHeader* data, UErrorCode &status);
174
176 friend class RBBIRuleBuilder;
178 friend class BreakIterator;
179
180 public:
181
186 RuleBasedBreakIterator();
187
194 RuleBasedBreakIterator(const RuleBasedBreakIterator& that);
195
204 RuleBasedBreakIterator( const UnicodeString &rules,
205 UParseError &parseError,
206 UErrorCode &status);
207
231 RuleBasedBreakIterator(const uint8_t *compiledRules,
232 uint32_t ruleLength,
233 UErrorCode &status);
234
247 RuleBasedBreakIterator(UDataMemory* image, UErrorCode &status);
248
253 virtual ~RuleBasedBreakIterator();
254
262 RuleBasedBreakIterator& operator=(const RuleBasedBreakIterator& that);
263
272 virtual UBool operator==(const BreakIterator& that) const;
273
281 UBool operator!=(const BreakIterator& that) const;
282
293 virtual BreakIterator* clone() const;
294
300 virtual int32_t hashCode(void) const;
301
307 virtual const UnicodeString& getRules(void) const;
308
309 //=======================================================================
310 // BreakIterator overrides
311 //=======================================================================
312
338 virtual CharacterIterator& getText(void) const;
339
340
355 virtual UText *getUText(UText *fillIn, UErrorCode &status) const;
356
364 virtual void adoptText(CharacterIterator* newText);
365
377 virtual void setText(const UnicodeString& newText);
378
392 virtual void setText(UText *text, UErrorCode &status);
393
399 virtual int32_t first(void);
400
406 virtual int32_t last(void);
407
418 virtual int32_t next(int32_t n);
419
425 virtual int32_t next(void);
426
432 virtual int32_t previous(void);
433
441 virtual int32_t following(int32_t offset);
442
450 virtual int32_t preceding(int32_t offset);
451
460 virtual UBool isBoundary(int32_t offset);
461
470 virtual int32_t current(void) const;
471
472
506 virtual int32_t getRuleStatus() const;
507
531 virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status);
532
544 virtual UClassID getDynamicClassID(void) const;
545
557 static UClassID U_EXPORT2 getStaticClassID(void);
558
585 virtual BreakIterator * createBufferClone(void *stackBuffer,
586 int32_t &BufferSize,
587 UErrorCode &status);
588
589
607 virtual const uint8_t *getBinaryRules(uint32_t &length);
608
634 virtual RuleBasedBreakIterator &refreshInputText(UText *input, UErrorCode &status);
635
636
637 private:
638 //=======================================================================
639 // implementation
640 //=======================================================================
646 void reset(void);
647
652 void setBreakType(int32_t type);
653
658 void init(UErrorCode &status);
659
668 int32_t handlePrevious(int32_t fromPosition);
669
682 int32_t handleNext();
683
684
691 const LanguageBreakEngine *getLanguageBreakEngine(UChar32 c);
692
693 public:
694 #ifndef U_HIDE_INTERNAL_API
695
699 void dumpCache();
700 #endif /* U_HIDE_INTERNAL_API */
701 };
702
703 //------------------------------------------------------------------------------
704 //
705 // Inline Functions Definitions ...
706 //
707 //------------------------------------------------------------------------------
708
709 inline UBool RuleBasedBreakIterator::operator!=(const BreakIterator& that) const {
710 return !operator==(that);
711 }
712
713 U_NAMESPACE_END
714
715 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
716
717 #endif
brkiter.h
C++ API: Break Iterator.
icu::BreakIterator::operator=
BreakIterator & operator=(const BreakIterator &other)
icu::BreakIterator::next
virtual int32_t next(void)=0
Advance the iterator to the boundary following the current boundary.
icu::BreakIterator::isBoundary
virtual UBool isBoundary(int32_t offset)=0
Return true if the specified position is a boundary position.
icu::BreakIterator::adoptText
virtual void adoptText(CharacterIterator *it)=0
Change the text over which this operates.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:93
icu::BreakIterator::getText
virtual CharacterIterator & getText(void) const =0
Return a CharacterIterator over the text being analyzed.
icu::BreakIterator::getUText
virtual UText * getUText(UText *fillIn, UErrorCode &status) const =0
Get a UText for the text being analyzed.
icu::BreakIterator::first
virtual int32_t first(void)=0
Sets the current iteration position to the beginning of the text, position zero.
icu::BreakIterator::following
virtual int32_t following(int32_t offset)=0
Advance the iterator to the first boundary following the specified offset.
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
icu::CharacterIterator
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:358
schriter.h
C++ API: String Character Iterator.
icu::UCharCharacterIterator
A concrete subclass of CharacterIterator that iterates over the characters (code units or code points...
Definition: uchriter.h:35
icu::StringCharacterIterator
A concrete subclass of CharacterIterator that iterates over the characters (code units or code points...
Definition: schriter.h:45
icu::BreakIterator
The BreakIterator class implements methods for finding the location of boundaries in text...
Definition: brkiter.h:102
icu::BreakIterator::last
virtual int32_t last(void)=0
Set the iterator position to the index immediately BEYOND the last character in the text being scanne...
icu::BreakIterator::current
virtual int32_t current(void) const =0
Return character index of the current iterator position within the text.
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:396
icu::BreakIterator::operator==
virtual UBool operator==(const BreakIterator &) const =0
Return true if another object is semantically equal to this one.
icu::BreakIterator::getRuleStatusVec
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 m...
udata.h
C API: Data loading interface.
UDataMemory
struct UDataMemory UDataMemory
Forward declaration of the data memory type.
Definition: udata.h:158
icu::BreakIterator::previous
virtual int32_t previous(void)=0
Set the iterator position to the boundary preceding the current boundary.
icu::BreakIterator::getRuleStatus
virtual int32_t getRuleStatus() const
For RuleBasedBreakIterators, return the status tag from the break rule that determined the most recen...
icu::BreakIterator::getDynamicClassID
virtual UClassID getDynamicClassID(void) const =0
Return a polymorphic class ID for this object.
icu::BreakIterator::setText
virtual void setText(const UnicodeString &text)=0
Change the text over which this operates.
icu::BreakIterator::refreshInputText
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...
icu::BreakIterator::clone
virtual BreakIterator * clone(void) const =0
Return a polymorphic copy of this object.
icu::BreakIterator::operator!=
UBool operator!=(const BreakIterator &rhs) const
Returns the complement of the result of operator==.
Definition: brkiter.h:131
uchriter.h
C++ API: char16_t Character Iterator.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
parseerr.h
C API: Parse Error Information.
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
icu::BreakIterator::createBufferClone
virtual BreakIterator * createBufferClone(void *stackBuffer, int32_t &BufferSize, UErrorCode &status)=0
Deprecated functionality.
UText
UText struct.
Definition: utext.h:1345
icu::RuleBasedBreakIterator
A subclass of BreakIterator whose behavior is specified using a list of rules.
Definition: rbbi.h:54
icu::BreakIterator::preceding
virtual int32_t preceding(int32_t offset)=0
Set the iterator position to the first boundary preceding the specified offset.
UParseError
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:359
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:286
icu::RuleBasedBreakIterator::operator!=
UBool operator!=(const BreakIterator &that) const
Not-equal operator.
Definition: rbbi.h:709
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236