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

wdbktbl.h

Go to the documentation of this file.
00001 /*
00002 *****************************************************************************************
00003 *                                                                                       
00004 * Copyright © {1997-1999}, International Business Machines Corporation and others. All Rights Reserved.
00005 *****************************************************************************************
00006 *
00007 * File WDBKTBL.H
00008 *
00009 * WordBreakTable implements a state transition table.
00010 *
00011 * @package  Text and International
00012 * @category Text Scanning
00013 *
00014 * Modification History:
00015 *
00016 *   Date        Name        Description
00017 *   02/18/97    aliu        Converted from OpenClass.  Made statics const.
00018 *****************************************************************************************
00019 */
00020 
00021 #ifndef WDBKTBL_H
00022 #define WDBKTBL_H
00023 
00024 #include "unicode/utypes.h"
00025 #include "txtbdat.h"
00026 
00035 class WordBreakTable {
00036 public:
00037     // For convenience
00038     typedef TextBoundaryData::Node Node;
00039     typedef TextBoundaryData::Type Type;
00040 
00050     WordBreakTable(int32_t cols, const Node data[], int32_t data_length);
00051 
00058     Node get(Node oldState, Type input) const;
00059 
00065     UBool isMarkState(Node state) const;
00066 
00072     UBool isEndState(Node state) const;
00073 
00078     Node initialState(void) const;
00079 
00080 private:
00081     static const Node  kMark_mask;
00082     static const Node  kIndex_mask;
00083 
00084     static const Node   kInitial_state;
00085     static const Node   kEnd_state;
00086 
00087     const TextBoundaryData::Node* fData;
00088     int32_t fData_length;
00089     int32_t fCols;
00090 };
00091 
00092 // -------------------------------------
00093 
00094 inline WordBreakTable::Node
00095 WordBreakTable::get(WordBreakTable::Node oldState, WordBreakTable::Type input) const
00096 {
00097     return fData[(oldState & kIndex_mask) * fCols + input];
00098 }
00099 
00100 inline UBool
00101 WordBreakTable::isMarkState(WordBreakTable::Node state) const
00102 {
00103     return (state & kMark_mask) != 0;
00104 }
00105 
00106 inline UBool
00107 WordBreakTable::isEndState(WordBreakTable::Node state) const
00108 {
00109     return (state & kIndex_mask) == kEnd_state;
00110 }
00111 
00112 inline WordBreakTable::Node
00113 WordBreakTable::initialState() const
00114 {
00115     return kInitial_state;
00116 }
00117 
00118 #endif // _WDBKTBL
00119 //eof

Generated at Tue Dec 5 17:55:38 2000 for ICU by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000