Class: TTransliterateRule

Declaration: Transliterate.h

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.

Member Function: TTransliterateRule::~TTransliterateRule

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.

Member Function: TTransliterateRule::GetKey

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:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TTransliterateRule::GetContext

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:

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.

Member Function: TTransliterateRule::GetResult

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:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TTransliterateRule::ContainsVariable

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:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TTransliterateRule::operator=

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.

Member Function: TTransliterateRule::operator<<=

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:

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.

Member Function: TTransliterateRule::operator>>=

virtual TStream & operator >>=(TStream & toWhere) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

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.

Member Function: TTransliterateRule::Hash

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.

Member Function: TTransliterateRule::GetResultLimit

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.

Member Function: TTransliterateRule::GetResultLength

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.

Member Function: TTransliterateRule::GetKeyLength

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.

Member Function: TTransliterateRule::DoesRuleApply

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:

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.

Member Function: TTransliterateRule::Translate

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:

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.

Member Function: TTransliterateRule::TTransliterateRule

  1. TTransliterateRule ()
  2. TTransliterateRule (const TTransliterateRule & rule)
  3. TTransliterateRule (const TText & keyText, const TText & resultText, const TText & preceedContext =TStandardText :: GetEmptyText (), const TText & succeedContext =TStandardText :: GetEmptyText ())

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Copy constructor.
  3. 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:

  1. Called by the stream-in operators.
  2. Called to copy an object.
  3. 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.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.