00001 /* 00002 * Copyright (C) {1999-2001}, International Business Machines Corporation and others. All Rights Reserved. 00003 ********************************************************************** 00004 * Date Name Description 00005 * 10/22/99 alan Creation. 00006 * 11/11/99 rgillam Complete port from Java. 00007 ********************************************************************** 00008 */ 00009 00010 #ifndef RBBI_H 00011 #define RBBI_H 00012 00013 #include "unicode/utypes.h" 00014 #include "unicode/brkiter.h" 00015 #include "unicode/udata.h" 00016 00017 class RuleBasedBreakIteratorTables; 00018 class BreakIterator; 00019 00184 class U_I18N_API RuleBasedBreakIterator : public BreakIterator { 00185 00186 public: 00190 static int8_t IGNORE; 00191 00192 private: 00196 static int16_t START_STATE; 00197 00201 static int16_t STOP_STATE; 00202 00203 protected: 00207 CharacterIterator* text; 00208 00212 RuleBasedBreakIteratorTables* tables; 00213 00214 private: 00218 static char fgClassID; 00219 /* 00220 * HSYS: To be revisited, once the ctor are made public. 00221 */ 00222 protected: 00223 //======================================================================= 00224 // constructors 00225 //======================================================================= 00226 00227 // This constructor uses the udata interface to create a BreakIterator whose 00228 // internal tables live in a memory-mapped file. "image" is a pointer to the 00229 // beginning of that file. 00230 RuleBasedBreakIterator(UDataMemory* image); 00231 00232 public: 00237 RuleBasedBreakIterator(const RuleBasedBreakIterator& that); 00238 00239 //======================================================================= 00240 // boilerplate 00241 //======================================================================= 00242 00246 virtual ~RuleBasedBreakIterator(); 00247 00252 RuleBasedBreakIterator& operator=(const RuleBasedBreakIterator& that); 00253 00258 virtual UBool operator==(const BreakIterator& that) const; 00259 00264 UBool operator!=(const BreakIterator& that) const; 00265 00270 virtual BreakIterator* clone(void) const; 00271 00276 virtual int32_t hashCode(void) const; 00277 00281 virtual const UnicodeString& getRules(void) const; 00282 00283 //======================================================================= 00284 // BreakIterator overrides 00285 //======================================================================= 00286 00294 virtual const CharacterIterator& getText(void) const; 00295 00296 #ifdef ICU_ENABLE_DEPRECATED_BREAKITERATOR 00297 00305 virtual CharacterIterator* createText(void) const; 00306 00316 virtual void setText(const UnicodeString* newText); 00317 #endif 00318 00325 virtual void adoptText(CharacterIterator* newText); 00326 00332 virtual void setText(const UnicodeString& newText); 00333 00339 virtual int32_t first(void); 00340 00346 virtual int32_t last(void); 00347 00357 virtual int32_t next(int32_t n); 00358 00363 virtual int32_t next(void); 00364 00369 virtual int32_t previous(void); 00370 00377 virtual int32_t following(int32_t offset); 00378 00385 virtual int32_t preceding(int32_t offset); 00386 00394 virtual UBool isBoundary(int32_t offset); 00395 00400 virtual int32_t current(void) const; 00401 00412 inline virtual UClassID getDynamicClassID(void) const; 00413 00424 inline static UClassID getStaticClassID(void); 00425 00426 virtual BreakIterator * createBufferClone(void *stackBuffer, 00427 int32_t &BufferSize, 00428 UErrorCode &status); 00429 00430 00431 protected: 00432 //======================================================================= 00433 // implementation 00434 //======================================================================= 00442 virtual int32_t handleNext(void); 00443 00451 virtual int32_t handlePrevious(void); 00452 00458 virtual void reset(void); 00459 00460 private: 00461 00466 RuleBasedBreakIterator(RuleBasedBreakIteratorTables* adoptTables); 00467 00468 friend class BreakIterator; 00469 00470 }; 00471 00472 inline UBool RuleBasedBreakIterator::operator!=(const BreakIterator& that) const { 00473 return !operator==(that); 00474 } 00475 00476 inline UClassID RuleBasedBreakIterator::getDynamicClassID(void) const { 00477 return RuleBasedBreakIterator::getStaticClassID(); 00478 } 00479 00480 inline UClassID RuleBasedBreakIterator::getStaticClassID(void) { 00481 return (UClassID)(&fgClassID); 00482 } 00483 00484 #endif