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

TransliterationRuleSet Class Reference

A set of rules for a RuleBasedTransliterator. More...

#include <rbt_set.h>

List of all members.

Public Methods

 TransliterationRuleSet ()
 Construct a new empty rule set.

 TransliterationRuleSet (const TransliterationRuleSet&)
 Copy constructor.

virtual ~TransliterationRuleSet ()
 Destructor.

virtual int32_t getMaximumContextLength (void) const
 Return the maximum context length. More...

virtual void addRule (TransliterationRule* adoptedRule, UErrorCode& status)
 Add a rule to this set. More...

virtual void freeze (const TransliterationRuleData& data, UErrorCode& status)
 Check this for masked rules and index it to optimize performance. More...

virtual TransliterationRulefindMatch (const Replaceable& text, const UTransPosition& pos, const TransliterationRuleData& data, const UnicodeFilter* filter) const
 Attempt to find a matching rule at the specified point in the text. More...

virtual TransliterationRulefindIncrementalMatch (const Replaceable& text, const UTransPosition& pos, const TransliterationRuleData& data, UBool& isPartial, const UnicodeFilter* filter) const
 Attempt to find a matching rule at the specified point in the text. More...


Detailed Description

A set of rules for a RuleBasedTransliterator.

This set encodes the transliteration in one direction from one set of characters or short strings to another. A RuleBasedTransliterator consists of up to two such sets, one for the forward direction, and one for the reverse.

A TransliterationRuleSet has one important operation, that of finding a matching rule at a given point in the text. This is accomplished by the findMatch() method.

Author(s):
Alan Liu

Definition at line 32 of file rbt_set.h.


Constructor & Destructor Documentation

TransliterationRuleSet::TransliterationRuleSet ( )
 

Construct a new empty rule set.

TransliterationRuleSet::TransliterationRuleSet ( const TransliterationRuleSet & )
 

Copy constructor.

TransliterationRuleSet::~TransliterationRuleSet ( ) [virtual]
 

Destructor.


Member Function Documentation

void TransliterationRuleSet::addRule ( TransliterationRule * adoptedRule,
UErrorCode & status ) [virtual]
 

Add a rule to this set.

Rules are added in order, and order is significant. The last call to this method must be followed by a call to freeze() before the rule set is used.

Parameters:
adoptedRule   the rule to add

TransliterationRule * TransliterationRuleSet::findIncrementalMatch ( const Replaceable & text,
const UTransPosition & pos,
const TransliterationRuleData & data,
UBool & isPartial,
const UnicodeFilter * filter ) const [virtual]
 

Attempt to find a matching rule at the specified point in the text.

Unlike findMatch(), this method does an incremental match. An incremental match requires that there be no partial matches that might pre-empt the full match that is found. If there are partial matches, then null is returned. A non-null result indicates that a full match has been found, and that it cannot be pre-empted by a partial match regardless of what additional text is added to the translation buffer.

Parameters:
text   the text, both translated and untranslated
start   the beginning index, inclusive; 0 <= start <= limit.
limit   the ending index, exclusive; start <= limit <= text.length().
cursor   position at which to translate next, representing offset into text. This value must be between start and limit.
data   a dictionary mapping variables to the sets they represent (maps Character to UnicodeSet)
partial   output parameter. partial[0] is set to true if a partial match is returned.
filter   the filter. Any character for which filter.isIn() returns false will not be altered by this transliterator. If filter is null then no filtering is applied.
Returns:
the matching rule, or null if none found, or if the text buffer does not have enough text yet to unambiguously match a rule.

TransliterationRule * TransliterationRuleSet::findMatch ( const Replaceable & text,
const UTransPosition & pos,
const TransliterationRuleData & data,
const UnicodeFilter * filter ) const [virtual]
 

Attempt to find a matching rule at the specified point in the text.

Parameters:
text   the text, both translated and untranslated
start   the beginning index, inclusive; 0 <= start <= limit.
limit   the ending index, exclusive; start <= limit <= text.length().
cursor   position at which to translate next, representing offset into text. This value must be between start and limit.
data   a dictionary mapping variables to the sets they represent (maps Character to UnicodeSet)
filter   the filter. Any character for which filter.isIn() returns false will not be altered by this transliterator. If filter is null then no filtering is applied.
Returns:
the matching rule, or null if none found.

void TransliterationRuleSet::freeze ( const TransliterationRuleData & data,
UErrorCode & status ) [virtual]
 

Check this for masked rules and index it to optimize performance.

The sequence of operations is: (1) add rules to a set using addRule(); (2) freeze the set using freeze(); (3) use the rule set. If addRule() is called after calling this method, it invalidates this object, and this method must be called again. That is, freeze() may be called multiple times, although for optimal performance it shouldn't be.

int32_t TransliterationRuleSet::getMaximumContextLength ( void ) const [virtual]
 

Return the maximum context length.

Returns:
the length of the longest preceding context.


The documentation for this class was generated from the following file:
Generated at Tue Dec 5 17:56:26 2000 for ICU by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000