00001 /* 00002 ********************************************************************** 00003 * Copyright (C) 1999-2001 IBM Corp. All rights reserved. 00004 ********************************************************************** 00005 * Date Name Description 00006 * 12/1/99 rgillam Complete port from Java. 00007 * 01/13/2000 helena Added UErrorCode to ctors. 00008 ********************************************************************** 00009 */ 00010 00011 #ifndef DBBI_H 00012 #define DBBI_H 00013 00014 #include "unicode/rbbi.h" 00015 00016 U_NAMESPACE_BEGIN 00017 00018 /* forward declaration */ 00019 class DictionaryBasedBreakIteratorTables; 00020 00049 class U_COMMON_API DictionaryBasedBreakIterator : public RuleBasedBreakIterator { 00050 00051 private: 00052 00059 int32_t* cachedBreakPositions; 00060 00064 int32_t numCachedBreakPositions; 00065 00070 int32_t positionInCache; 00071 00072 DictionaryBasedBreakIteratorTables *fTables; 00073 00077 static const char fgClassID; 00078 00092 DictionaryBasedBreakIterator(UDataMemory* tablesImage, const char* dictionaryFilename, UErrorCode& status); 00093 00094 public: 00095 //======================================================================= 00096 // boilerplate 00097 //======================================================================= 00098 00102 virtual ~DictionaryBasedBreakIterator(); 00103 00109 DictionaryBasedBreakIterator(); 00110 00116 DictionaryBasedBreakIterator(const DictionaryBasedBreakIterator &other); 00117 00123 DictionaryBasedBreakIterator& operator=(const DictionaryBasedBreakIterator& that); 00124 00130 virtual BreakIterator* clone(void) const; 00131 00132 //======================================================================= 00133 // BreakIterator overrides 00134 //======================================================================= 00139 virtual int32_t previous(void); 00140 00147 virtual int32_t following(int32_t offset); 00148 00155 virtual int32_t preceding(int32_t offset); 00156 00167 virtual UClassID getDynamicClassID(void) const; 00168 00179 static UClassID getStaticClassID(void); 00180 00181 protected: 00182 //======================================================================= 00183 // implementation 00184 //======================================================================= 00192 virtual int32_t handleNext(void); 00193 00198 virtual void reset(void); 00199 00200 // 00201 // init Initialize a dbbi. Common routine for use by constructors. 00202 // 00203 void init(); 00204 00218 virtual BreakIterator * createBufferClone(void *stackBuffer, 00219 int32_t &BufferSize, 00220 UErrorCode &status); 00221 00222 00223 private: 00235 void divideUpDictionaryRange(int32_t startPos, int32_t endPos, UErrorCode &status); 00236 00237 00238 /* 00239 * HSYS : Please revisit with Rich, the ctors of the DBBI class is currently 00240 * marked as private. 00241 */ 00242 friend class DictionaryBasedBreakIteratorTables; 00243 friend class BreakIterator; 00244 }; 00245 00246 inline UClassID DictionaryBasedBreakIterator::getDynamicClassID(void) const { 00247 return RuleBasedBreakIterator::getStaticClassID(); 00248 } 00249 00250 inline UClassID DictionaryBasedBreakIterator::getStaticClassID(void) { 00251 return (UClassID)(&fgClassID); 00252 } 00253 00254 U_NAMESPACE_END 00255 00256 #endif