00001 /* 00002 * Copyright © {1999}, 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 00304 virtual CharacterIterator* createText(void) const; 00305 00312 virtual void adoptText(CharacterIterator* newText); 00313 00319 virtual void setText(const UnicodeString& newText); 00320 00330 virtual void setText(const UnicodeString* newText); 00331 00337 virtual int32_t first(void); 00338 00344 virtual int32_t last(void); 00345 00355 virtual int32_t next(int32_t n); 00356 00361 virtual int32_t next(void); 00362 00367 virtual int32_t previous(void); 00368 00375 virtual int32_t following(int32_t offset); 00376 00383 virtual int32_t preceding(int32_t offset); 00384 00392 virtual UBool isBoundary(int32_t offset); 00393 00398 virtual int32_t current(void) const; 00399 00410 inline virtual UClassID getDynamicClassID(void) const; 00411 00422 inline static UClassID getStaticClassID(void); 00423 00424 protected: 00425 //======================================================================= 00426 // implementation 00427 //======================================================================= 00435 virtual int32_t handleNext(void); 00436 00444 virtual int32_t handlePrevious(void); 00445 00451 virtual void reset(void); 00452 00453 private: 00454 00459 RuleBasedBreakIterator(RuleBasedBreakIteratorTables* tables); 00460 00461 friend class BreakIterator; 00462 }; 00463 00464 inline UBool RuleBasedBreakIterator::operator!=(const BreakIterator& that) const { 00465 return !operator==(that); 00466 } 00467 00468 inline UClassID RuleBasedBreakIterator::getDynamicClassID(void) const { 00469 return RuleBasedBreakIterator::getStaticClassID(); 00470 } 00471 00472 inline UClassID RuleBasedBreakIterator::getStaticClassID(void) { 00473 return (UClassID)(&fgClassID); 00474 } 00475 00476 #endif