Class: TToken

Declaration: Tokens.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TUnicodeArray

Inherited By:

None.

Purpose:

TToken, derived from TUnicodeArray, encapsulates a constant, fast string of Unicode characters. Tokens are assigned a unique identifier at instantiation, allowing them to be shared by all running programs. A given token is given the same identifier no matter how many times it is instantiated. After instantiation, the string encapsulated by a token can be replaced but not edited.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

Do not derive from this class.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: TToken::TToken

  1. TToken (const char nullTerminated [])
  2. TToken (const UniChar that [], TTextCount thatLength)
  3. TToken (const TText & that)
  4. TToken (const TToken & that)
  5. TToken ()

Interface Category:

API.

Purpose:

  1. Constructs a token for the given character string.
  2. Constructs a token for the given character string.
  3. Constructs a token for the character string encapsulated by a text instance.
  4. Copy constructor.
  5. Default constructor.

Calling Context:

  1. Called to construct a token for a character string.
  2. Called to construct a token for a character string.
  3. Called to construct a token for a character string encapsulated by a text instance.
  4. Called to copy an object.
  5. Called by the stream-in operators.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TToken::~TToken

virtual ~ TToken ()

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: TToken::operator=

TToken & operator =(const TToken & that)

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.

Member Function: TToken::operator==

bool operator ==(const TToken & that) const

Interface Category:

API.

Purpose:

Equality operator.

Calling Context:

Call to compare two instances of this class.

Parameters:

Return Value:

Returns true if the objects are equal.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TToken::Hash

virtual long Hash () const

Interface Category:

API.

Purpose:

Overrides inherited MCollectible function.

Calling Context:

Same as for base class.

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: TToken::operator>>=

virtual TStream & operator >>=(TStream &) 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: TToken::operator<<=

virtual TStream & operator <<= (TStream &)

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: TToken::GetLength

virtual TTextCount GetLength () const

Interface Category:

API.

Purpose:

Returns the length of the encapsulated character string.

Calling Context:

Call to get the length of the encapsulated character string. If the length is 0, the token is invalid.

Parameters:

Return Value:

The length of the encapsulated character string.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TToken::GetData

  1. virtual TTextCount GetData (UniChar that [], TTextCount thatLength) const
  2. virtual TTextCount GetData (UniChar that [], TTextCount thatLength, const TTextRange & thisRange) const
  3. virtual TTextCount GetData (char that [], TTextCount thatLength) const
  4. virtual TTextCount GetData (char that [], TTextCount thatLength, const TTextRange & thisRange) const

Interface Category:

API.

Purpose:

  1. Gets the character string encapsulated by the token as a UniChar array.
  2. Gets the character string encapsulated by the token as a UniChar array.
  3. Gets the character string encapsulated by the token as a char array.
  4. Gets the character string encapsulated by the token as a char array.

Calling Context:

  1. Call to get the character string encapsulated by the token.
  2. Call to get the character string encapsulated by the token.
  3. Call to get the character string encapsulated by the token.
  4. Call to get the character string encapsulated by the token.

Parameters:

Return Value:

The actual length of the returned array.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TToken::SetData

  1. virtual void SetData (const UniChar that [], const TTextRange & thatRange)
  2. virtual void SetData (const char that [], const TTextRange & thatRange)

Interface Category:

API.

Purpose:

  1. Replaces the string in the token with the specified string.
  2. Replaces the string in the token with the specified string.

Calling Context:

  1. Call to replace the string in the token with the specified string.
  2. Call to replace the string in the token with the specified string.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function provides the only mechanism for changing a token after instantiation.

Member Function: TToken::IsValid

bool IsValid () const

Interface Category:

API.

Purpose:

Queries whether a token is valid. A token is invalid if it contains a string of length 0; that is, no string.

Calling Context:

Call to query whether a token is valid.

Parameters:

Return Value:

Returns true if the token is valid.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TToken::GetInvalidToken

static const TToken & GetInvalidToken ()

Interface Category:

API.

Purpose:

Returns an invalid token instance.

Calling Context:

Call to get an invalid token.

Parameters:

Return Value:

An invalid TToken instance.

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.