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 U_NAMESPACE_BEGIN 00018 00019 class RuleBasedBreakIteratorTables; 00020 class BreakIterator; 00021 00186 class U_I18N_API RuleBasedBreakIterator : public BreakIterator { 00187 00188 public: 00192 static const int8_t IGNORE; 00193 00194 private: 00198 static const int16_t START_STATE; 00199 00203 static const int16_t STOP_STATE; 00204 00205 protected: 00209 CharacterIterator* text; 00210 00214 RuleBasedBreakIteratorTables* tables; 00215 00216 private: 00220 static const char fgClassID; 00221 /* 00222 * HSYS: To be revisited, once the ctor are made public. 00223 */ 00224 protected: 00225 //======================================================================= 00226 // constructors 00227 //======================================================================= 00228 00229 // This constructor uses the udata interface to create a BreakIterator whose 00230 // internal tables live in a memory-mapped file. "image" is a pointer to the 00231 // beginning of that file. 00232 RuleBasedBreakIterator(UDataMemory* image); 00233 00234 public: 00239 RuleBasedBreakIterator(const RuleBasedBreakIterator& that); 00240 00241 //======================================================================= 00242 // boilerplate 00243 //======================================================================= 00244 00248 virtual ~RuleBasedBreakIterator(); 00249 00254 RuleBasedBreakIterator& operator=(const RuleBasedBreakIterator& that); 00255 00260 virtual UBool operator==(const BreakIterator& that) const; 00261 00266 UBool operator!=(const BreakIterator& that) const; 00267 00272 virtual BreakIterator* clone(void) const; 00273 00278 virtual int32_t hashCode(void) const; 00279 00283 virtual const UnicodeString& getRules(void) const; 00284 00285 //======================================================================= 00286 // BreakIterator overrides 00287 //======================================================================= 00288 00296 virtual const CharacterIterator& getText(void) const; 00297 00298 #ifdef ICU_ENABLE_DEPRECATED_BREAKITERATOR 00307 virtual CharacterIterator* createText(void) const; 00308 00318 virtual void setText(const UnicodeString* newText); 00319 #endif 00320 00327 virtual void adoptText(CharacterIterator* newText); 00328 00334 virtual void setText(const UnicodeString& newText); 00335 00341 virtual int32_t first(void); 00342 00348 virtual int32_t last(void); 00349 00359 virtual int32_t next(int32_t n); 00360 00365 virtual int32_t next(void); 00366 00371 virtual int32_t previous(void); 00372 00379 virtual int32_t following(int32_t offset); 00380 00387 virtual int32_t preceding(int32_t offset); 00388 00396 virtual UBool isBoundary(int32_t offset); 00397 00402 virtual int32_t current(void) const; 00403 00414 inline virtual UClassID getDynamicClassID(void) const; 00415 00426 inline static UClassID getStaticClassID(void); 00427 00428 virtual BreakIterator * createBufferClone(void *stackBuffer, 00429 int32_t &BufferSize, 00430 UErrorCode &status); 00431 00432 00433 protected: 00434 //======================================================================= 00435 // implementation 00436 //======================================================================= 00444 virtual int32_t handleNext(void); 00445 00453 virtual int32_t handlePrevious(void); 00454 00460 virtual void reset(void); 00461 00462 private: 00463 00468 RuleBasedBreakIterator(RuleBasedBreakIteratorTables* adoptTables); 00469 00470 friend class BreakIterator; 00471 00472 }; 00473 00474 inline UBool RuleBasedBreakIterator::operator!=(const BreakIterator& that) const { 00475 return !operator==(that); 00476 } 00477 00478 inline UClassID RuleBasedBreakIterator::getDynamicClassID(void) const { 00479 return RuleBasedBreakIterator::getStaticClassID(); 00480 } 00481 00482 inline UClassID RuleBasedBreakIterator::getStaticClassID(void) { 00483 return (UClassID)(&fgClassID); 00484 } 00485 00486 U_NAMESPACE_END 00487 00488 #endif