Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

rbbi.h

Go to the documentation of this file.
00001 /*
00002 ***************************************************************************
00003 *   Copyright (C) 1999-2003 International Business Machines Corporation   *
00004 *   and others. All rights reserved.                                      *
00005 ***************************************************************************
00006 
00007 **********************************************************************
00008 *   Date        Name        Description
00009 *   10/22/99    alan        Creation.
00010 *   11/11/99    rgillam     Complete port from Java.
00011 **********************************************************************
00012 */
00013 
00014 #ifndef RBBI_H
00015 #define RBBI_H
00016 
00017 #include "unicode/utypes.h"
00018 
00019 #if !UCONFIG_NO_BREAK_ITERATION
00020 
00021 #include "unicode/brkiter.h"
00022 #include "unicode/udata.h"
00023 #include "unicode/parseerr.h"
00024 
00025 struct UTrie;
00026 
00027 U_NAMESPACE_BEGIN
00028 
00029 struct RBBIDataHeader;
00030 class  RuleBasedBreakIteratorTables;
00031 class  BreakIterator;
00032 class  RBBIDataWrapper;
00033 struct RBBIStateTable;
00034 
00035 
00036 
00051 class U_COMMON_API RuleBasedBreakIterator : public BreakIterator {
00052 
00053 protected:
00058     CharacterIterator*  fText;
00059 
00064     RBBIDataWrapper    *fData;
00065 
00069     int32_t             fLastBreakTag;
00070 
00077     UBool               fLastBreakTagValid;
00078 
00086     uint32_t           fDictionaryCharCount;
00087 
00092     static UBool        fTrace;
00093 
00094 
00095 protected:
00096     //=======================================================================
00097     // constructors
00098     //=======================================================================
00099 
00110     RuleBasedBreakIterator(RBBIDataHeader* data, UErrorCode &status);
00111 
00112     friend class RBBIRuleBuilder; 
00113     friend class BreakIterator;
00114 
00115 
00116 
00117 public:
00118 
00123     RuleBasedBreakIterator();
00124 
00131     RuleBasedBreakIterator(const RuleBasedBreakIterator& that);
00132 
00141     RuleBasedBreakIterator( const UnicodeString    &rules,
00142                              UParseError           &parseError,
00143                              UErrorCode            &status);
00144 
00145 
00156     RuleBasedBreakIterator(UDataMemory* image, UErrorCode &status);
00157 
00162     virtual ~RuleBasedBreakIterator();
00163 
00171     RuleBasedBreakIterator& operator=(const RuleBasedBreakIterator& that);
00172 
00181     virtual UBool operator==(const BreakIterator& that) const;
00182 
00190     UBool operator!=(const BreakIterator& that) const;
00191 
00201     virtual BreakIterator* clone() const;
00202 
00208     virtual int32_t hashCode(void) const;
00209 
00215     virtual const UnicodeString& getRules(void) const;
00216 
00217     //=======================================================================
00218     // BreakIterator overrides
00219     //=======================================================================
00220 
00229     virtual const CharacterIterator& getText(void) const;
00230 
00231 
00239     virtual void adoptText(CharacterIterator* newText);
00240 
00247     virtual void setText(const UnicodeString& newText);
00248 
00255     virtual int32_t first(void);
00256 
00263     virtual int32_t last(void);
00264 
00275     virtual int32_t next(int32_t n);
00276 
00282     virtual int32_t next(void);
00283 
00289     virtual int32_t previous(void);
00290 
00298     virtual int32_t following(int32_t offset);
00299 
00307     virtual int32_t preceding(int32_t offset);
00308 
00317     virtual UBool isBoundary(int32_t offset);
00318 
00324     virtual int32_t current(void) const;
00325 
00326 
00348     virtual int32_t getRuleStatus() const;
00349 
00361     virtual UClassID getDynamicClassID(void) const;
00362 
00374     static UClassID getStaticClassID(void);
00375 
00376     /*
00377      * Create a clone (copy) of this break iterator in memory provided
00378      *  by the caller.  The idea is to increase performance by avoiding
00379      *  a storage allocation.  Use of this functoin is NOT RECOMMENDED.
00380      *  Performance gains are minimal, and correct buffer management is
00381      *  tricky.  Use clone() instead.
00382      *
00383      * @param stackBuffer  The pointer to the memory into which the cloned object
00384      *                     should be placed.  If NULL,  allocate heap memory
00385      *                     for the cloned object.
00386      * @param BufferSize   The size of the buffer.  If zero, return the required
00387      *                     buffer size, but do not clone the object.  If the
00388      *                     size was too small (but not zero), allocate heap
00389      *                     storage for the cloned object.
00390      *
00391      * @param status       Error status.  U_SAFECLONE_ALLOCATED_WARNING will be
00392      *                     returned if the the provided buffer was too small, and
00393      *                     the clone was therefore put on the heap.
00394      *
00395      * @return  Pointer to the clone object.  This may differ from the stackBuffer
00396      *          address if the byte alignment of the stack buffer was not suitable
00397      *          or if the stackBuffer was too small to hold the clone.
00398      * @stable ICU 2.0
00399      */
00400     virtual BreakIterator *  createBufferClone(void *stackBuffer,
00401                                                int32_t &BufferSize,
00402                                                UErrorCode &status);
00403 
00404 
00422     virtual const uint8_t *getBinaryRules(uint32_t &length);
00423 
00424 
00425 protected:
00426     //=======================================================================
00427     // implementation
00428     //=======================================================================
00437     virtual int32_t handleNext(void);
00438 
00447     virtual int32_t handlePrevious(void);
00448 
00455     virtual void reset(void);
00456 
00465     virtual UBool isDictionaryChar(UChar32);
00466 
00472     void init();
00473 
00474 private:
00475 
00485     int32_t handlePrevious(const RBBIStateTable *statetable);
00486 
00496     int32_t handleNext(const RBBIStateTable *statetable);
00497 };
00498 
00499 //------------------------------------------------------------------------------
00500 //
00501 //   Inline Functions Definitions ...
00502 //
00503 //------------------------------------------------------------------------------
00504 
00505 inline UBool RuleBasedBreakIterator::operator!=(const BreakIterator& that) const {
00506     return !operator==(that);
00507 }
00508 
00509 U_NAMESPACE_END
00510 
00511 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
00512 
00513 #endif

Generated on Mon Nov 24 14:35:35 2003 for ICU 2.8 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001