Taxonomy Categories:
Member Functions:
Interface Category:
API.
Inherits From:
MCollectible
Inherited By:
None.
Purpose:
TTransliterateRule objects are used by TRuleBasedTransliterator. Each rule consists of a key, a result, and optional context information. For example, a simple rule of the form red>green will translate instances of red into green. If one only wishes to change red when it occurs in the phrase red light, light can be specified in the context information. Context is used when searching for a matching rule, but is not translated. The rules support variables to denote a range or list of characters for greater flexibility.
Instantiation:
Allocate on the heap or the stack.
Deriving Classes:
TTransliterateRule is a concrete class designed to be used directly by TRuleBasedTransliterator. It should not be derived.
Concurrency:
Not multithread safe.
Resource Use:
No special requirements.
virtual ~ TTransliterateRule ()
Interface Category:
API.
Purpose:
Destructor.
Calling Context:
This function is designed to be called directly and has no special requirements.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
void GetKey (TText & key, TTextRange & keyRange) const
Interface Category:
API.
Purpose:
Returns the key portion of this rule.
Calling Context:
This function is designed to be called directly and has no special requirements.
Parameters:
- TText & key -The key text.
- TTextRange & keyRange -The range of the key text.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
bool GetContext (TText & preceedingContext, TText & succeedingContext) const
Interface Category:
API.
Purpose:
Returns the preceding and succeeding context text for this rule.
Calling Context:
This function is designed to be called directly and has no special requirements.
Parameters:
- TText & preceedingContext -The preceding context text.
- TText & succeedingContext -The succeeding context text.
Return Value:
Returns true if the context text for this rule is not empty.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
void GetResult (TText & result) const
Interface Category:
API.
Purpose:
Returns the result portion of this rule.
Calling Context:
This function is designed to be called directly and has no special requirements.
Parameters:
- TText & result -The result text.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual bool ContainsVariable () const
Interface Category:
API.
Purpose:
Queries whether this rule contains a variable.
Calling Context:
This function is designed to be called directly and has no special requirements.
Parameters:
Return Value:
Returns true if this rule contains a variable.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TTransliterateRule::SetContainsVariable
virtual void SetContainsVariable (const bool containsRange)
Interface Category:
API.
Purpose:
Specify that this rule does or does not contain a variable.
Calling Context:
This function is designed to be called directly and has no special requirements.
Parameters:
- const bool containsRange -Whether or not this rule contains a variable.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
TTransliterateRule & operator =(const TTransliterateRule & rule)
Interface Category:
API.
Purpose:
Assignment operator.
Calling Context:
This function is designed to be called directly and has no special requirements.
Parameters:
Return Value:
A non-const reference to the left-hand side object.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual TStream & operator <<= (TStream & fromWhere)
Interface Category:
API.
Purpose:
Stream-in operator.
Calling Context:
This function is designed to be called directly and has no special requirements.
Parameters:
- TStream & fromWhere -The stream the object streams itself in from.
Return Value:
Returns a reference to the stream the object streams itself in from.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual TStream & operator >>=(TStream & toWhere) const
Interface Category:
API.
Purpose:
Stream-out operator.
Calling Context:
Called to stream out data.
Parameters:
- TStream & toWhere -The stream the object streams itself out to.
Return Value:
Returns a reference to the stream the object streams itself out to.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual long Hash () const
Interface Category:
API.
Purpose:
Generates a hash value.
Calling Context:
This function is designed to be called directly and has no special requirements.
Parameters:
Return Value:
The numeric value of the hash.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
TTextOffset GetResultLimit () const
Interface Category:
API.
Purpose:
Returns the limiting bound of the result text.
Calling Context:
This function is designed to be called directly and has no special requirements.
Parameters:
Return Value:
The limit of the result text.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
TTextCount GetResultLength () const
Interface Category:
API.
Purpose:
Returns the length of the result portion of the rule.
Calling Context:
This function is designed to be called directly and has no special requirements.
Parameters:
Return Value:
The length of the result portion of the rule.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
TTextCount GetKeyLength () const
Interface Category:
API.
Purpose:
Returns the length of the key portion of the rule.
Calling Context:
This function is designed to be called directly and has no special requirements.
Parameters:
Return Value:
The length of the key portion of the rule.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual bool DoesRuleApply (const TText & text, TTextOffset textOffset, const TDictionary & variableTable, bool & variableMatch, TTextCount & translatableChars) const
Interface Category:
API.
Purpose:
Determines if the rule defined by this object applies to a given text object, in context of the variable table argument.
Calling Context:
This function is designed to be called directly and has no special requirements.
Parameters:
- const TText & text -The text object.
- TTextOffset textOffset -Offset in text where translation should start.
- const TDictionary & variableTable -The rule variable table.
- bool & variableMatch -Set to true if the rule applies only because a variable was matched (variable match has lower precedence than an exact match).
- TTextCount & translatableChars -Set to the number of characters in the text that were matched by the rule.
Return Value:
Returns true if the rule can be applied to the text.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual TTextOffset Translate (TText & sourceText, TTextOffset & sourceOffset, TTextCount & numReplacedChars, TTextCount & numNewChars) const
Interface Category:
API.
Purpose:
Uses the rule described by the current object to perform translation.
Calling Context:
This function is called internally by TRuleBasedTransliterator::Translate.
Parameters:
- TText & sourceText -The text to be translated.
- TTextOffset & sourceOffset -Offset in sourceText where translation should start. This is updated by the function to refer to the last character translated.
- TTextCount & numReplacedChars -Number of characters converted. This is used to keep track of the replacement range.
- TTextCount & numNewChars -Number of additional characters introduced by the translation.
Return Value:
Returns the position of the first character translated in sourceText. If translation is not possible, the return value is -1.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
- TTransliterateRule ()
- TTransliterateRule (const TTransliterateRule & rule)
- TTransliterateRule (const TText & keyText, const TText & resultText, const TText & preceedContext =TStandardText :: GetEmptyText (), const TText & succeedContext =TStandardText :: GetEmptyText ())
Interface Category:
API.
Purpose:
- Default constructor.
- Copy constructor.
- Constructs a rule with the specified key, result, preceding context and succeeding context. Note: these four components cannot exceed 256 characters in length.
Calling Context:
- Called by the stream-in operators.
- Called to copy an object.
- This function is designed to be called directly and has no special requirements.
Parameters:
- Takes no parameters.
- const TTransliterateRule & rule -The object to copy.
- const TText & keyText -The key text to be translated.
- const TText & resultText -The translation for the key text.
- const TText & preceedContext =TStandardText :: GetEmptyText () -The preceding context. If argument is empty text (the default), then there is no preceding context for this rule.
- const TText & succeedContext =TStandardText :: GetEmptyText () -The succeeding context. If argument is empty text (the default), then there is no succeeding context for this rule.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.