![](../../Home/Icons/Home.gif)
![](../icons/UpCNM.gif)
![](../icons/CNMContext.gif)
![](../../Home/Icons/Search.gif)
Taxonomy Categories:
Member Functions:
Interface Category:
API.
Inherits From:
TNumberFormatter
Inherited By:
None.
Purpose:
This class, derived from TNumberFormatter, handles rational numbers, formatting them as either proper or improper fractions.
Note: The Scan function currently does not handle the sign correctly for rational numbers. Negative numbers might be scanned as positive numbers. This will be fixed in the next release.
Instantiation:
Always allocate on the heap.
Deriving Classes:
Derived classes must override the TextToCanonicalNumber and CanonicalNumberToText functions.
Concurrency:
Not multithread safe.
Resource Use:
No special requirements.
- TRationalNumberFormatter ()
- TRationalNumberFormatter (EFractionPropriety thePropriety, bool useSuperScript, EFractionDirection theFractionDirection =kNumeratorFirst)
- TRationalNumberFormatter (const TRationalNumberFormatter &)
Interface Category:
API.
Purpose:
- Default constructor. Creates a formatter with these characteristics: formats proper fractions, puts the numerator first, superscripts the numerator, subscripts the denominator, uses a space between the integer and the fraction, uses a slash between the numerator and the denominator, does not style the numerator or denominator text, and uses a TUnicodeDecimalNumerals object to map characters to values.
- Creates a formatter with the specified propriety, superscripting, and direction. This formatter will have the other characteristics of the default formatter.
- Copy constructor.
Calling Context:
- Called by the stream-in operators and and directly to instantiate this class.
- Call this function directly.
- Called to copy an object.
Parameters:
- Takes no parameters.
- EFractionPropriety thePropriety -Indicates whether the formatter creates proper or improper fractions.
- bool useSuperScript -Indicates whether the two parts of the fraction should be superscripted and subscripted.
- EFractionDirection theFractionDirection =kNumeratorFirst -Indicates the direction of the formatted fractions.
- const TRationalNumberFormatter & -The object to copy.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual ~ TRationalNumberFormatter ()
Interface Category:
API.
Purpose:
Destructor.
Calling Context:
Called to destroy an object.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void SetUpCanonicalNumberConverter ()
Interface Category:
API.
Purpose:
Sets up the canonical number converter for use in converting between binary numbers and text.
Calling Context:
Called by the Format and Scan functions.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void TextToCanonicalNumber (const TText &, TCanonicalNumber &, TNumberScanResult &, const TTextRange &)
Interface Category:
API.
Purpose:
During a scanning operation, converts a text string into a TCanonicalNumber object. The scanning function then uses a TCanonicalNumberConverter to convert the canonical number to a binary number.
Calling Context:
Called by the Scan member function when converting a text string into a numeral.
Parameters:
- const TText & -Contains the text string to scan.
- TCanonicalNumber & -Receives the canonical number produced by the conversion.
- TNumberScanResult & -Receives information about the result of the scanning operation.
- const TTextRange & -Specifies the range of the text string to scan.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void CanonicalNumberToText (const TCanonicalNumber &, TText &, TNumberFormatResult &)
Interface Category:
API.
Purpose:
During a formatting operation, converts a TCanonicalNumber object into a text string. The formatting function first uses a TCanonicalNumberConverter to convert the binary number into the canonical number.
Calling Context:
Called by the Format function when converting a numeral into a text string.
Parameters:
- const TCanonicalNumber & -Specifies the canonical number to convert.
- TText & -Receives the text string produced by the conversion.
- TNumberFormatResult & -Receives information about the result of the formatting operation.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual double GetVariance () const
Interface Category:
API.
Purpose:
Gets the precision requirement for how close the fraction value must be to the decimal value. The default value is 0.0000005.
Calling Context:
Called during conversion operations.
Parameters:
Return Value:
The precision requirement.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void SetVariance (double)
Interface Category:
API.
Purpose:
Sets the precision requirement for how close the fraction value must be to the decimal value.
Calling Context:
Call this function directly.
Parameters:
- double -The precision requirement.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void GetFractionSpace (TText &) const
Interface Category:
API.
Purpose:
Gets the text used to separate the integer part of the value from the fractional part of the value.
Calling Context:
Calling during the formatting operation.
Parameters:
- TText & -Receives the text used to separate the integer part of the value from the fractional part of the value.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void SetFractionSpace (const TText &)
Interface Category:
API.
Purpose:
Sets the text used to separate the integer part of the value from the fractional part of the value.
Calling Context:
Call this function directly.
Parameters:
- const TText & -The text string used to separate the integer part of the value from the fractional part of the value.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void GetFractionSign (TText &) const
Interface Category:
API.
Purpose:
Gets the text used to separate the numerator from the denominator.
Calling Context:
Calling during the formatting operation.
Parameters:
- TText & -Receives the text used to separate the numerator from the denominator.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void SetFractionSign (const TText &)
Interface Category:
API.
Purpose:
Sets the text used to separate the numerator from the denominator.
Calling Context:
Call this function directly.
Parameters:
- const TText & -The text to use to separate the numerator from the denominator.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual EFractionPropriety GetFractionPropriety () const
Interface Category:
API.
Purpose:
Gets the EFractionPropriety value specifying whether formatted fractions should be proper or improper.
Calling Context:
Calling during the formatting operation.
Parameters:
Return Value:
Returns the EFractionPropriety value, either kProperFraction or kImproperFraction.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void SetFractionPropriety (EFractionPropriety)
Interface Category:
API.
Purpose:
Specifies whether formatted fractions should be proper or improper.
Calling Context:
Call this function directly.
Parameters:
- EFractionPropriety -Specifies either kProperFraction or kImproperFraction.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual bool GetSuperscriptUse () const
Interface Category:
API.
Purpose:
Queries whether the formatter is set to superscript the first element of the fraction and subscript the second element of the fraction.
Calling Context:
Calling during the formatting operation.
Parameters:
Return Value:
Returns true if the formatter is set to superscript the first element of the fraction and subscript the second element of the fraction.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void SetSuperscriptUse (const bool)
Interface Category:
API.
Purpose:
Specifies whether the formatter should superscript the first element of the fraction and subscript the second element of the fraction.
Calling Context:
Call this function directly.
Parameters:
- const bool -Set to true to superscript the first element of the fraction and subscript the second element of the fraction.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void GetNumeratorStyle (TStyleSet &) const
Interface Category:
API.
Purpose:
Gets the style set used when formatting the numerator into a text string.
Calling Context:
Calling during the formatting operation.
Parameters:
- TStyleSet & -Receives the style set used when formatting the numerator into a text string.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void SetNumeratorStyle (const TStyleSet &)
Interface Category:
API.
Purpose:
Sets the style set used when formatting the numerator into a text string.
Calling Context:
Call this function directly.
Parameters:
- const TStyleSet & -The style set to use when formatting the numerator into a text string.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void GetDenominatorStyle (TStyleSet &) const
Interface Category:
API.
Purpose:
Gets the style set used when formatting the denominator into a text string.
Calling Context:
Calling during the formatting operation.
Parameters:
- TStyleSet & -Receives the style set to use when formatting the denominator into a text string.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void SetDenominatorStyle (const TStyleSet &)
Interface Category:
API.
Purpose:
Sets the style set used when formatting the denominator into a text string.
Calling Context:
Call this function directly.
Parameters:
- const TStyleSet & -The style set to use when formatting the denominator into a text string.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual EFractionDirection GetFractionDirection () const
Interface Category:
API.
Purpose:
Queries whether the formatter is set to display the numerator or the denominator first. By default, the numerator appears first.
Calling Context:
Calling during the formatting operation.
Parameters:
Return Value:
Returns the EFractionDirection value, either kNumeratorFirst or kDenominatorFirst.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void SetFractionDirection (EFractionDirection)
Interface Category:
API.
Purpose:
Specifies whether the numerator or the denominator should appear first.
Calling Context:
Call this function directly.
Parameters:
- EFractionDirection -Specifies either kNumeratorFirst or kDenominatorFirst.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual TNumberFormatter * GetIntegerFormatter () const
Interface Category:
API.
Purpose:
Gets a pointer to the number formatter used to format each integral portion of the number (the integer, the numerator, and the denominator).
Calling Context:
Calling during the formatting operation.
Parameters:
Return Value:
A pointer to the integer formatter.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void AdoptIntegerFormatter (TNumberFormatter *)
Interface Category:
API.
Purpose:
Specifies a pointer to the number formatter to use to format each integral portion of the number (the integer, the numerator, and the denominator).
Calling Context:
Call this function directly.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
TRationalNumberFormatter & operator =(const TRationalNumberFormatter &)
Interface Category:
API.
Purpose:
Assignment operator.
Calling Context:
Called when an object is assigned to another compatible object.
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 & toWhere) const
Interface Category:
API.
Purpose:
Stream-out operator.
Calling Context:
Called to stream out data.
Parameters:
- TStream & toWhere -The stream the object is streamed 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 TStream & operator <<= (TStream & fromWhere)
Interface Category:
API.
Purpose:
Stream-in operator.
Calling Context:
Called to stream in data.
Parameters:
- TStream & fromWhere -The stream the object is streamed in from.
Return Value:
Returns a reference to the stream the object streams itself in from.
Exceptions:
Throws a TStandardException if the version of the formatter cannot be used on the current system.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual bool IsEqual (const MCollectible * obj) const
Interface Category:
API.
Purpose:
Compares two objects for equality.
Calling Context:
Called to compare compatible objects.
Parameters:
Return Value:
Returns true if the objects match.
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:
Called to generate a hash value.
Parameters:
Return Value:
The numeric value of the hash.
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.