2 ***************************************************************************
3 * Copyright (C) 2006-2008 Apple Inc. All Rights Reserved. *
4 ***************************************************************************
10 #include "unicode/utypes.h"
14 * \brief C++ API: Rule Based Tokenizer
17 #if !UCONFIG_NO_BREAK_ITERATION
19 #include "unicode/urbtok.h"
20 #include "unicode/rbbi.h"
21 #include "unicode/parseerr.h"
27 struct RBBIDataHeader
;
28 struct RBBIStateTableRow
;
33 * A subclass of RuleBasedBreakIterator that adds tokenization functionality.
35 * <p>This class is for internal use only by Apple Computer, Inc.</p>
38 class U_COMMON_API RuleBasedTokenizer
: public RuleBasedBreakIterator
{
42 * The row corresponding to the start state
45 const RBBIStateTableRow
*fStartRow
;
48 * The merged flag results for accepting states
54 * Character categories for the Latin1 subset of Unicode
61 * Construct a RuleBasedTokenizer from a set of rules supplied as a string.
62 * @param rules The break rules to be used.
63 * @param parseError In the event of a syntax error in the rules, provides the location
64 * within the rules of the problem.
65 * @param status Information on any errors encountered.
68 RuleBasedTokenizer(const UnicodeString
&rules
, UParseError
&parseErr
, UErrorCode
&status
);
71 * Constructor from a flattened set of RBBI data in uprv_malloc'd memory.
72 * RulesBasedBreakIterators built from a custom set of rules
73 * are created via this constructor; the rules are compiled
74 * into memory, then the break iterator is constructed here.
76 * The break iterator adopts the memory, and will
80 RuleBasedTokenizer(uint8_t *data
, UErrorCode
&status
);
83 * Constructor from a flattened set of RBBI data in umemory which need not
84 * be malloced (e.g. it may be a memory-mapped file, etc.).
86 * This version does not adopt the memory, and does not
93 RuleBasedTokenizer(const uint8_t *data
, enum EDontAdopt dontAdopt
, UErrorCode
&status
);
99 virtual ~RuleBasedTokenizer();
102 * Fetch the next set of tokens.
103 * @param maxTokens The maximum number of tokens to return.
104 * @param outTokenRanges Pointer to output array of token ranges.
105 * @param outTokenFlags (optional) pointer to output array of token flags.
108 int32_t tokenize(int32_t maxTokens
, RuleBasedTokenRange
*outTokenRanges
, unsigned long *outTokenFlags
);
112 * Common initialization function, used by constructors.
120 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */