ICU 54.1 54.1

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

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rbbi.h
Go to the documentation of this file.
1 /*
2 ***************************************************************************
3 * Copyright (C) 1999-2014 International Business Machines Corporation *
4 * and others. All rights reserved. *
5 ***************************************************************************
6
7 **********************************************************************
8 * Date Name Description
9 * 10/22/99 alan Creation.
10 * 11/11/99 rgillam Complete port from Java.
11 **********************************************************************
12 */
13
14 #ifndef RBBI_H
15 #define RBBI_H
16
17 #include "unicode/utypes.h"
18
24 #if !UCONFIG_NO_BREAK_ITERATION
25
26 #include "unicode/brkiter.h"
27 #include "unicode/udata.h"
28 #include "unicode/parseerr.h"
29 #include "unicode/schriter.h"
30 #include "unicode/uchriter.h"
31
32
33 struct UTrie;
34
35 U_NAMESPACE_BEGIN
36
38 struct RBBIDataHeader;
39 class RuleBasedBreakIteratorTables;
40 class BreakIterator;
41 class RBBIDataWrapper;
42 class UStack;
43 class LanguageBreakEngine;
44 class UnhandledEngine;
45 struct RBBIStateTable;
46
47
48
49
65 class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator {
66
67 protected:
72 UText *fText;
73
79 CharacterIterator *fCharIter;
80
86 StringCharacterIterator *fSCharIter;
87
93 UCharCharacterIterator *fDCharIter;
94
99 RBBIDataWrapper *fData;
100
104 int32_t fLastRuleStatusIndex;
105
112 UBool fLastStatusIndexValid;
113
119 uint32_t fDictionaryCharCount;
120
128 int32_t* fCachedBreakPositions;
129
134 int32_t fNumCachedBreakPositions;
135
141 int32_t fPositionInCache;
142
150 UStack *fLanguageBreakEngines;
151
159 UnhandledEngine *fUnhandledBreakEngine;
160
166 int32_t fBreakType;
167
168 protected:
169 //=======================================================================
170 // constructors
171 //=======================================================================
172
173 #ifndef U_HIDE_INTERNAL_API
174
182 enum EDontAdopt {
183 kDontAdopt
184 };
185
196 RuleBasedBreakIterator(RBBIDataHeader* data, UErrorCode &status);
197
206 RuleBasedBreakIterator(const RBBIDataHeader* data, enum EDontAdopt dontAdopt, UErrorCode &status);
207 #endif /* U_HIDE_INTERNAL_API */
208
209
210 friend class RBBIRuleBuilder;
212 friend class BreakIterator;
213
214
215
216 public:
217
222 RuleBasedBreakIterator();
223
230 RuleBasedBreakIterator(const RuleBasedBreakIterator& that);
231
240 RuleBasedBreakIterator( const UnicodeString &rules,
241 UParseError &parseError,
242 UErrorCode &status);
243
267 RuleBasedBreakIterator(const uint8_t *compiledRules,
268 uint32_t ruleLength,
269 UErrorCode &status);
270
283 RuleBasedBreakIterator(UDataMemory* image, UErrorCode &status);
284
289 virtual ~RuleBasedBreakIterator();
290
298 RuleBasedBreakIterator& operator=(const RuleBasedBreakIterator& that);
299
308 virtual UBool operator==(const BreakIterator& that) const;
309
317 UBool operator!=(const BreakIterator& that) const;
318
329 virtual BreakIterator* clone() const;
330
336 virtual int32_t hashCode(void) const;
337
343 virtual const UnicodeString& getRules(void) const;
344
345 //=======================================================================
346 // BreakIterator overrides
347 //=======================================================================
348
374 virtual CharacterIterator& getText(void) const;
375
376
391 virtual UText *getUText(UText *fillIn, UErrorCode &status) const;
392
400 virtual void adoptText(CharacterIterator* newText);
401
408 virtual void setText(const UnicodeString& newText);
409
423 virtual void setText(UText *text, UErrorCode &status);
424
430 virtual int32_t first(void);
431
437 virtual int32_t last(void);
438
449 virtual int32_t next(int32_t n);
450
456 virtual int32_t next(void);
457
463 virtual int32_t previous(void);
464
472 virtual int32_t following(int32_t offset);
473
481 virtual int32_t preceding(int32_t offset);
482
491 virtual UBool isBoundary(int32_t offset);
492
498 virtual int32_t current(void) const;
499
500
533 virtual int32_t getRuleStatus() const;
534
558 virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status);
559
571 virtual UClassID getDynamicClassID(void) const;
572
584 static UClassID U_EXPORT2 getStaticClassID(void);
585
612 virtual BreakIterator * createBufferClone(void *stackBuffer,
613 int32_t &BufferSize,
614 UErrorCode &status);
615
616
634 virtual const uint8_t *getBinaryRules(uint32_t &length);
635
661 virtual RuleBasedBreakIterator &refreshInputText(UText *input, UErrorCode &status);
662
663
664 protected:
665 //=======================================================================
666 // implementation
667 //=======================================================================
673 virtual void reset(void);
674
675 #if 0
676
684 virtual UBool isDictionaryChar(UChar32);
685
690 virtual int32_t getBreakType() const;
691 #endif
692
697 virtual void setBreakType(int32_t type);
698
699 #ifndef U_HIDE_INTERNAL_API
700
704 void init();
705 #endif /* U_HIDE_INTERNAL_API */
706
707 private:
708
718 int32_t handlePrevious(const RBBIStateTable *statetable);
719
729 int32_t handleNext(const RBBIStateTable *statetable);
730
731 protected:
732
733 #ifndef U_HIDE_INTERNAL_API
734
748 int32_t checkDictionary(int32_t startPos, int32_t endPos, UBool reverse);
749 #endif /* U_HIDE_INTERNAL_API */
750
751 private:
752
759 const LanguageBreakEngine *getLanguageBreakEngine(UChar32 c);
760
764 void makeRuleStatusValid();
765
766 };
767
768 //------------------------------------------------------------------------------
769 //
770 // Inline Functions Definitions ...
771 //
772 //------------------------------------------------------------------------------
773
774 inline UBool RuleBasedBreakIterator::operator!=(const BreakIterator& that) const {
775 return !operator==(that);
776 }
777
778 U_NAMESPACE_END
779
780 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
781
782 #endif