Class: TFormatter

Declaration: Formatter.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

MCollectible

Inherited By:

TChoiceFormatter TDateTimeFormatter TNumberFormatter TParameterFormatter TSimpleTextFormatter

Purpose:

Abstract base class for formatters (objects that perform conversions between text and binary data). Each TFormatter can format the derived classes of a given TFormattable class. A main usage of TFormatter is by TParameterFormatter, which can format text roughly like sprintf.

Instantiation:

Abstract class; do not allocate.

Deriving Classes:

This is the base class all other formatters should derive from. Derived classes must provide the following functions: Format, Scan, CreateFormattable, CreateScanResult, and CreateFormatResult.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: TFormatter::~TFormatter

virtual ~ TFormatter ()

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.

Member Function: TFormatter::Hash

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.

Member Function: TFormatter::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: TFormatter::operator<<=

virtual TStream & operator <<= (TStream & fromWhere)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

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: TFormatter::Format

virtual void Format (const TFormattable & value, TText & text, TFormatResult & conversionResult) const

Interface Category:

API.

Purpose:

Given a value, encapsulated by an object of a TFormattable class, returns formatted text.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

TFormatter derived classes throw an exception if the wrong type of TFormattable is passed in.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TFormatter::Scan

virtual void Scan (const TText & text, const TTextRange & inputRange, TFormattable & value, TScanResult & conversionResult) const

Interface Category:

API.

Purpose:

Given a text object, scans and parses it to return a value.

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.

Member Function: TFormatter::CreateFormattable

virtual TFormattable * CreateFormattable () const

Interface Category:

API.

Purpose:

Creates the formattable used by this formatter.

Calling Context:

Called by the Scan function.

Parameters:

Return Value:

Returns a TFormattable object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TFormatter::CreateScanResult

virtual TScanResult * CreateScanResult () const

Interface Category:

API.

Purpose:

Creates an object of the TScanResult class used by this formatter.

Calling Context:

Called by the Scan function.

Parameters:

Return Value:

Returns a TScanResult object. The caller owns the storage.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TFormatter::CreateFormatResult

virtual TFormatResult * CreateFormatResult () const

Interface Category:

API.

Purpose:

Creates an object of the TFormatResult class used by this formatter.

Calling Context:

Called by the Format function.

Parameters:

Return Value:

Returns a TFormatResult object. The caller owns the storage.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TFormatter::TFormatter

  1. TFormatter ()
  2. TFormatter (const TFormatter &)

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Copy constructor.

Calling Context:

  1. Called by the stream-in operators.
  2. Called to copy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TFormatter::operator=

TFormatter & operator =(const TFormatter &)

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.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.