Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: e32std.h
Link against: euser.lib

Class TLex16

TLex16

Support

Supported from 5.0

Description

Provides general string-parsing functions suitable for numeric format conversions and syntactical-element parsing. The class is the 16 bit variant for Unicode strings and 16 bit wide characters.

An instance of this class stores a string, maintaining an extraction mark to indicate the current lexical element being analysed and a pointer to the next character to be examined.

Objects of this type are normally accessed through the build independent type TLex.

Defined in TLex16:
Assign(), Eos(), Get(), Inc(), Mark(), MarkedOffset(), MarkedToken(), NextToken(), Offset(), Peek(), Remainder(), RemainderFromMark(), SkipAndMark(), SkipCharacters(), SkipSpace(), SkipSpaceAndMark(), TLex16(), TokenLength(), UnGet(), UnGetToMark(), Val(), operator=()

See also:


Construction and destruction


TLex16()

TLex16();

Description

Constructs a TLex16, initialising its members to NULL.


TLex16()

TLex16(const TUint16* aString);

Description

Constructs the object with a pointer to a string. The extraction mark and next character members are initialised to point to the start of the string.

Parameters

const TUint16* aString

String to be assigned.


TLex16()

TLex16(const TDesC16& aDes);

Description

Constructs the object with a descriptor. The extraction mark and next character members are initialised to point to the start of the string.

Parameters

const TDesC16& aDes

Descriptor to be assigned by reference


TLex16()

TLex16(const TLex16& aLex);

Description

Constructs the object with a TLex16.

Parameters

const TLex16& aLex

TLex16 to be copied by reference.

[Top]


Lexical analysis


Mark()

void Mark();

Description

Sets the TLex16’s next character position to its extraction mark.


Mark()

void Mark(TLexMark16& aMark) const;

Description

Sets the supplied extraction mark to the TLex16’s next character position.

Parameters

TLexMark16& aMark

On return, set to the next character position


Inc()

void Inc();

Description

Increments to the next character position.

Note:


Inc()

void Inc(TInt aNumber);

Description

Increments the next character position by aNumber.

Parameters

TInt aNumber

The number of characters to increment the next character position by. If the increment puts the next character position before the start or beyond the end of the string, the function panics.

See also:


Peek()

TChar Peek() const;

Description

Shows the next character to be returned by Get().

Return value

TChar

Character to be returned by Get(). Returns 0 if at the end of the string.

See also:


Get()

TChar Get();

Description

Gets the next character in the string and increments the next character position.

Return value

TChar

Next character to be read. Returns 0 if at the end of the string.


UnGet()

void UnGet();

Description

Decrements the next character position, allowing the previously "got" character to be re-read.

Note:

See also:


UnGetToMark()

void UnGetToMark();

Description

Sets the next character position to the current extraction mark position.

Note:


UnGetToMark()

void UnGetToMark(const TLexMark16 aMark);

Description

Sets the next character position to the supplied extraction mark position.

Parameters

const TLexMark16& aMark

Mark to copy to the next character position. If the extraction mark is before the start or beyond the end of the string, the function panics.

See also:


SkipSpace()

void SkipSpace();

Description

Moves the next character position past any white space (space or separator). Stops if at the end of string.


SkipSpaceAndMark()

void SkipSpaceAndMark();

Description

Moves the next character position past any white space and copies it to the TLex16’s extraction mark. Stops if at the end of the string.


SkipSpaceAndMark()

void SkipSpaceAndMark(TLexMark16& aMark);

Description

Moves the next character position past any white space and copies it to the specified extraction mark. Stops if at the end of the string.

Parameters

TLexMark16& aMark

On return contains a reference to the next character position.


SkipCharacters()

void SkipCharacters();

Description

Moves the next character position to the next white space (space or separator). Stops if at the end of the string.

See also:


SkipAndMark()

void SkipAndMark(TInt aNumber);

Description

Moves the next character position a specified number of characters. Stops if at the end of the string.

Parameters

TInt aNumber

Number of characters to skip. If the skip moves the next character position to before the start or beyond the end of the string, the function panics.


SkipAndMark()

void SkipAndMark(TInt aNumber, TLexMark16& aMark);

Description

Moves the next character position a specified number of characters and copies it to the specified extraction mark. Stops if at the end of the string.

Parameters

TInt aNumber

Number of characters to skip. If the skip moves the next character position to before the start or beyond the end of the string, the function panics.

TLexMark16& aMark

On return, set to the next character position.

[Top]


Tokens

Description

A token is considered to be a character string delimited by white space (space or separator).


TokenLength()

TInt TokenLength() const;

Description

Gets the length of the token. This is the difference of the next character position and the extraction mark.

Note:

Return value

TInt

Length of the token.

See also:


TokenLength()

TInt TokenLength(const TLexMark16 aMark) const;

Description

Gets the length of the token starting at the specified extraction mark.

Parameters

const TLexMark16& aMark

Extraction mark indicating the start of the token. If this mark is before the start or beyond the end of the string, the function panics.

Return value

TInt

Length of the token.


MarkedToken()

TPtrC16 MarkedToken() const;

Description

Extracts the marked token.

Note:

Return value

TPtrC16

Extracted token.


MarkedToken()

TPtrC16 MarkedToken(const TLexMark16 aMark) const;

Description

Extracts the token, starting at the specified mark

Parameters

const TLexMark16& aMark

Extraction mark indicating the start of the token. If this mark is before the start or beyond the end of the string, the function panics.

Return value

TPtrC16

Extracted token.


NextToken()

TPtrC16 NextToken();

Description

Strips any white space and extracts the next token.

Return value

TPtrC16

Extracted token.

[Top]


Getting the remaining text


Remainder()

TPtrC16 Remainder() const;

Description

Gets a descriptor containing all the text from the next character position to the end of the string.

Note:

Return value

TPtrC16

Text from the next character position onwards.


RemainderFromMark()

TPtrC16 RemainderFromMark() const;

Description

Gets a descriptor containing all the text from the extraction mark to the end of the string.

Note

Return value

TPtrC16

Text from the extraction mark onwards.


RemainderFromMark()

TPtrC16 RemainderFromMark(const TLexMark16 aMark) const;

Description

Gets a descriptor containing all the text from the specified extraction mark to the end of the string.

Parameters

const TLexMark16& aMark

Extraction mark indicating where remaining text starts. If this mark is before the start or beyond the end of the string, the function panics.

Return value

TPtrC16

Text from the specified extraction mark onwards.

[Top]


Offsets


Offset()

TInt Offset() const;

Description

Gets the offset of the next character position from the start of the string.

Return value

TInt

Offset of next character position.

See also:


MarkedOffset()

TInt MarkedOffset() const;

Description

Gets the offset of the extraction mark from the start of the string.

Return value

TInt

The offset of the extraction mark.


MarkedOffset()

TInt MarkedOffset(const TLexMark16 aMark) const;

Description

Gets the offset of the specified extraction mark from the start of the string.

Parameters

const TLexMark16 aMark

Extraction mark. If this mark is before the start or beyond the end of the string, the function panics.

Return value

TInt

The offset of the extraction mark.

[Top]


Signed integer conversion


Val()

TInt Val(TInt& aVal);

Description

Parses the string to extract a signed integer.

Parameters

TInt& aVal

On return, contains the extracted integer.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

TInt Val(TInt8& aVal);

Description

Parses the string to extract a signed 8 bit integer.

Parameters

TInt8& aVal

On return, contains the extracted integer.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

TInt Val(TInt16& aVal);

Description

Parses the string to extract a signed 16 bit integer.

Parameters

TInt16& aVal

On return, contains the extracted integer.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

TInt Val(TInt32& aVal);

Description

Parses the string to extract a signed 32 bit integer.

Parameters

TInt32& aVal

On return, contains the extracted integer.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

TInt Val(TInt64& aVal);

Description

Parses the string to extract a signed 64 bit integer.

Parameters

TInt64& aVal

On return, contains the extracted integer.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.

[Top]


Signed integer conversion with limit check


Val()

TInt Val(TInt32& aVal,TInt aLimit);

Description

Parses the string to extract a signed 32 bit integer, and returnsKErrOverflow if the integer exceeds a specified limit.

Parameters

TInt32& aVal

On return, contains the extracted integer.

TInt aLimit

Limit value.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

TInt Val(TInt64& aVal,const TInt64& aLimit);

Description

Parses the string to extract a signed 64 bit integer, and returnsKErrOverflow if the integer exceeds a specified limit.

Parameters

TInt64& aVal

On return, contains the extracted integer.

const TInt64& aLimit

Limit value.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.

[Top]


Unsigned integer conversion


Val()

TInt Val(TUint& aVal,TRadix aRadix=EDecimal);

Description

Parses the string to extract an unsigned integer, using a specified radix. The specified radix is one of binary, octal, decimal, or hexadecimal.

Parameters

TUint& aVal

On return, contains the extracted integer.

TRadix aRadix

Radix to use when converting number. The default radix for this function overload is decimal.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

TInt Val(TUint8& aVal,TRadix aRadix);

Description

Parses the string to extract an 8 bit unsigned integer, using a specified radix. The specified radix is one of binary, octal, decimal, or hexadecimal.

Parameters

TUint8& aVal

On return, contains the extracted integer.

TRadix aRadix

Radix to use when converting number.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

TInt Val(TUint16& aVal,TRadix aRadix);

Description

Parses the string to extract a 16 bit unsigned integer, using a specified radix. The specified radix is one of binary, octal, decimal, or hexadecimal.

Parameters

TUint16& aVal

On return, contains the extracted integer.

TRadix aRadix

Radix to use when converting number.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

TInt Val(TUint32& aVal,TRadix aRadix);

Description

Parses the string to extract a 32 bit unsigned integer, using a specified radix. The specified radix is one of binary, octal, decimal, or hexadecimal.

Parameters

TUint32& aVal

On return, contains the extracted integer.

TRadix aRadix

Radix to use when converting number.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

TInt Val(TInt64& aVal,TRadix aRadix);

Description

Parses the string to extract a 64 bit unsigned integer, using a specified radix. The specified radix is one of binary, octal, decimal, or hexadecimal.

Parameters

TInt64& aVal

On return, contains the extracted integer.

TRadix aRadix

Radix to use when converting number.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.

[Top]


Unsigned integer conversion with limit check


Val()

TInt Val(TUint32& aVal,TRadix aRadix,TUint aLimit);

Description

Parses the string to extract an unsigned 32 bit integer using a specified radix, and returns KErrOverflow if the integer exceeds a specified limit.

Parameters

TUint32& aVal

On return, contains the extracted integer.

TRadix aRadix

Radix to use when converting number.

TUint aLimit

Limit value.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

TInt Val(TInt64& aVal,TRadix aRadix,const TInt64& aLimit);

Description

Parses the string to extract an unsigned 64 bit integer using a specified radix, and returns KErrOverflow if the integer exceeds a specified limit.

Parameters

TInt64& aVal

On return, contains the extracted integer.

TRadix aRadix

Radix to use when converting number.

const TInt64& aLimit

Limit value.

Return value

TInt

KErrNone if successful, KErrGeneral if the next character position initially at end of string or no valid characters found initially, or KErrOverflow if there is sign overflow — converted value greater than limit. If error codesKErrGeneral or KErrOverflow are returned, the object's members are left unaltered.

[Top]


Real number conversion


Val()

TInt Val(TReal32& aVal);

Description

Parses the string to extract a 32 bit real number. The character interpreted as the decimal point is the current locale's decimal separator value.

Parameters

TReal32& aVal

On return, contains the extracted number.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


Val()

TInt Val(TReal64& aVal);

Description

Parses the string to extract a 64 bit real number. The character interpreted as the decimal point is the current locale's decimal separator value.

Parameters

TReal64& aVal

On return, contains the extracted number.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

[Top]


Real number conversion, specifying character for decimal point


Val()

TInt Val(TReal32& aVal,TChar aPoint);

Description

Parses the string to extract a 32 bit real number, specifying the character to be interpreted as the decimal point.

Parameters

TReal32& aVal

On return, contains the extracted number.

TChar aPoint

Character to be interpreted as the decimal point.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


Val()

TInt Val(TReal64& aVal,TChar aPoint);

Description

Parses the string to extract a 64 bit real number, specifying the character to be interpreted as the decimal point.

Parameters

TReal64& aVal

On return, contains the extracted number.

TChar aPoint

Character to be interpreted as the decimal point.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

[Top]


Assignment operators


operator=()

TLex16& operator=(const TLex16& aLex);

Description

Allows TLex16 objects to be assigned to aTLex16when the = operator is overloaded.

Parameters

const TLex16& aLex

TLex16 to be assigned to the TLex16.

Return value

TLex16&

TLex16 descriptor


operator=()

TLex16& operator=(const TUint16* aString);

Description

Allows descriptors to be assigned to a TLex16 when the = operator is overloaded.

Parameters

const TUint16* aString

String to be assigned to the TLex16.

Return value

TLex16&

TLex16 descriptor


operator=()

TLex16& operator=(const TDesC16& aDes);

Description

Allows pointers to strings to be assigned to a TLex16 when the = operator is overloaded.

Parameters

const TDesC16& aDes

Descriptor to be assigned to the TLex16.

Return value

TLex16&

TLex16 descriptor

[Top]


Assign string to be lexed from various sources


Assign()

void Assign(const TLex16& aLex);
void Assign(const TUint16* aString);
void Assign(const TDesC16& aDes);

Description

Assigns a string to this object from another TLex16 object, from another string or from a descriptor.

Parameters

const TLex16& aLex

The object to be assigned.

const TUint16* aString

A pointer to a string to be assigned.

const TDesC16& aDes

A descriptor containing a string to be assigned

[Top]


Basic functions


Eos()

TBool Eos() const;

Description

Tests to see if the next character position is at the end of the string.

Return value

TBool

True if at end of string, false otherwise.