Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: e32std.h
Link against: euser.lib

Class TLex16

class TLex16;

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.

Members

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

See also:


Construction and destruction


TLex16()

IMPORT_C TLex16();

Description

Default cosntructor.

Constructs a TLex16, initialising its members to NULL.


TLex16()

inline 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()

inline 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.

[Top]


Member functions


operator=()

inline TLex16 &operator=(const TUint16 *aString);

Description

Allows strings to be assigned to a TLex16.

Parameters

const TUint16 *aString

String to be assigned to the TLex16.

Return value

TLex16 &

TLex16 descriptor.


operator=()

inline TLex16 &operator=(const TDesC16 &aDes);

Description

Allows descriptors to be assigned to a TLex16.

Parameters

const TDesC16 &aDes

Descriptor to be assigned to the TLex16.

Return value

TLex16 &

TLex8 descriptor.


Eos()

inline TBool Eos() const;

Description

Tests whether the next character position is at the end of the string.

Return value

TBool

True if at end of string, false otherwise.


Mark()

inline void Mark();

Description

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


Mark()

inline 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()

IMPORT_C void Inc();

Description

Increments to the next character position.

Panic codes

USER

65, if the increment puts the next character position before the start or beyond the end of the string.


Inc()

IMPORT_C 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.

Panic codes

USER

65, if the increment puts the next character position before the start or beyond the end of the string.


Get()

IMPORT_C TChar Get();

Description

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

Return value

TChar

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


Peek()

IMPORT_C TChar Peek() const;

Description

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

Return value

TChar

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


UnGet()

IMPORT_C void UnGet();

Description

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

Panic codes

USER

64, if the previous character is before the start of the string.


UnGetToMark()

inline void UnGetToMark();

Description

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

Panic codes

USER

68, if the specified mark is before the start or beyond the end of the string.


UnGetToMark()

IMPORT_C 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.

Panic codes

USER

68, if the extraction mark is before the start or beyond the end of the string.


SkipSpace()

IMPORT_C void SkipSpace();

Description

Moves the next character position past any white space (space or separator).

Stops if at the end of string.


SkipAndMark()

inline void SkipAndMark(TInt aNumber);

Description

Moves the next character position a specified number of characters.

Parameters

TInt aNumber

Number of characters to skip.

Panic codes

USER

68, if the skip moves the next character position either to before the start or beyond the end of the string.


SkipAndMark()

IMPORT_C 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.

Parameters

TInt aNumber

Number of characters to skip.

TLexMark16 &aMark

On return, set to the next character position.

Panic codes

USER

66, if the skip moves the next character position either to before the start or beyond the end of the string.


SkipSpaceAndMark()

IMPORT_C 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.


SkipSpaceAndMark()

inline 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.


SkipCharacters()

IMPORT_C void SkipCharacters();

Description

Moves the next character position to the next white space (space or separator).

Stops if at the end of the string.


TokenLength()

inline TInt TokenLength() const;

Description

Gets the length of the token.

This is the difference between the next character position and the extraction mark.

Return value

TInt

Length of the token.


TokenLength()

IMPORT_C 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.

Return value

TInt

Length of the token.

Panic codes

USER

68, if the specified mark is before the start or beyond the end of the string.


MarkedToken()

IMPORT_C TPtrC16 MarkedToken() const;

Description

Extracts the marked token.

Note that the function assumes that the current extraction mark is valid.

Return value

TPtrC16

Extracted token.

Panic codes

USER

68, if the specified mark is before the start or beyond the end of the string.


MarkedToken()

IMPORT_C 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.

Return value

TPtrC16

Extracted token.

Panic codes

USER

68, if the specified mark is before the start or beyond the end of the string.


NextToken()

IMPORT_C TPtrC16 NextToken();

Description

Strips any white space and extracts the next token.

Return value

TPtrC16

Extracted token.


Remainder()

IMPORT_C TPtrC16 Remainder() const;

Description

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

Return value

TPtrC16

Text from the next character position onwards.

Panic codes

USER

17, if the value of (next character position - extraction mark) is negative.


RemainderFromMark()

IMPORT_C TPtrC16 RemainderFromMark() const;

Description

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

The function assumes that the current extraction mark is valid.

Return value

TPtrC16

Text from the extraction mark onwards.


RemainderFromMark()

IMPORT_C 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.

Return value

TPtrC16

Text from the specified extraction mark onwards.

Panic codes

USER

17, if the value of (next character position - extraction mark) is negative.

USER

68, if the specified mark is before the start or beyond the end of the string.


Offset()

IMPORT_C 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.


MarkedOffset()

inline 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()

IMPORT_C 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.

Return value

TInt

The offset of the extraction mark.

Panic codes

USER

68, if the specified mark is before the start or beyond the end of the string.


Val()

IMPORT_C 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 is initially at the end of the string or no valid characters found initially. KErrOverflow if there is sign overflow, i.e. converted value greater than limit. If error codes KErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

IMPORT_C 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 is initially at the end of the string or no valid characters found initially. KErrOverflow if there is sign overflow, i.e. converted value greater than limit. If error codes KErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

IMPORT_C 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 is initially at the end of the string or no valid characters found initially. KErrOverflow if there is sign overflow, i.e. converted value greater than limit. If error codes KErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

IMPORT_C 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 is initially at the end of the string or no valid characters found initially. KErrOverflow if there is sign overflow, i.e. converted value greater than limit. If error codes KErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

inline 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 is initially at the end of the string or no valid characters found initially. KErrOverflow if there is sign overflow, i.e. converted value greater than limit. If error codes KErrGeneral or KErrOverflow are returned, the object's members are left unaltered.


Val()

IMPORT_C TInt Val(TUint8 &aVal, TRadix aRadix);

Description

Parses the string to extract an 8-bit unsigned integer, using the specified radix.

The specified radix is one of binary, octal, decimal, or hexadecimal.

Parameters

TUint8 &aVal

On return, contains the extracted integer.

TRadix aRadix

The radix to use when converting the number.

Return value

TInt

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


Val()

IMPORT_C TInt Val(TUint16 &aVal, TRadix aRadix);

Description

Parses the string to extract a 16-bit unsigned integer, using the specified radix.

The specified radix is one of binary, octal, decimal, or hexadecimal.

Parameters

TUint16 &aVal

On return, contains the extracted integer.

TRadix aRadix

The radix to use when converting the number.

Return value

TInt

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


Val()

IMPORT_C TInt Val(TUint32 &aVal, TRadix aRadix);

Description

Parses the string to extract a 32-bit unsigned integer, using the specified radix.

The specified radix is one of binary, octal, decimal, or hexadecimal.

Parameters

TUint32 &aVal

On return, contains the extracted integer.

TRadix aRadix

The radix to use when converting the number.

Return value

TInt

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


Val()

IMPORT_C TInt Val(TInt64 &aVal, TRadix aRadix);

Description

Parses the string to extract a 64-bit integer (treated as unsigned), using the specified radix.

The specified radix is one of binary, octal, decimal, or hexadecimal.

Parameters

TInt64 &aVal

On return, contains the extracted integer.

TRadix aRadix

The radix to use when converting the number.

Return value

TInt

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


Val()

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

Description

Parses the string to extract an unsigned integer, using the specified radix.

Parameters

TUint &aVal

On return, contains the extracted integer.

TRadix aRadix

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

Return value

TInt

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


BoundedVal()

IMPORT_C TInt BoundedVal(TInt32 &aVal, TInt aLimit);

Description

Parses the string to extract a 32-bit signed integer, and checks that it is within the specified limit.

Parameters

TInt32 &aVal

On return, contains the extracted integer.

TInt aLimit

The upper limit.

Return value

TInt

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


BoundedVal()

IMPORT_C TInt BoundedVal(TInt64 &aVal, const TInt64 &aLimit);

Description

Parses the string to extract a 64-bit signed integer, and checks that it is within the specified limit.

Parameters

TInt64 &aVal

On return, contains the extracted integer.

const TInt64 &aLimit

The upper limit.

Return value

TInt

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


BoundedVal()

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

Description

Parses the string to extract a 32-bit unsigned integer, using the specified radix, and checks that it is within the specified limit.

The specified radix is one of binary, octal, decimal, or hexadecimal.

Parameters

TUint32 &aVal

On return, contains the extracted integer.

TRadix aRadix

The radix to use when converting the number.

TUint aLimit

The upper limit.

Return value

TInt

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


BoundedVal()

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

Description

Parses the string to extract a 64-bit signed integer, using the specified radix, and checks that it is within the specified limit.

The specified radix is one of binary, octal, decimal, or hexadecimal.

Parameters

TInt64 &aVal

On return, contains the extracted integer.

TRadix aRadix

The radix to use when converting the number.

const TInt64 &aLimit

The upper limit.

Return value

TInt

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


Val()

IMPORT_C TInt Val(TReal32 &aVal);

Description

Parameters

TReal32 &aVal

Return value

TInt


Val()

IMPORT_C TInt Val(TReal32 &aVal, TChar aPoint);

Description

Parameters

TReal32 &aVal

TChar aPoint

Return value

TInt


Val()

IMPORT_C TInt Val(TReal64 &aVal);

Description

Parameters

TReal64 &aVal

Return value

TInt


Val()

IMPORT_C TInt Val(TReal64 &aVal, TChar aPoint);

Description

Parameters

TReal64 &aVal

TChar aPoint

Return value

TInt


Assign()

inline void Assign(const TLex16 &aLex);

Description

Assigns a string to this object from another TLex16 object.

Parameters

const TLex16 &aLex

The object to be assigned.


Assign()

IMPORT_C void Assign(const TUint16 *aString);

Description

Assigns a string to this object from another string.

Parameters

const TUint16 *aString

A pointer to a string to be assigned.


Assign()

IMPORT_C void Assign(const TDesC16 &aDes);

Description

Assigns a string to this object from a descriptor.

Parameters

const TDesC16 &aDes

The descriptor to be assigned.


Val()

inline TInt Val(TInt32 &aVal, TInt aLimit);

Description

Parameters

TInt32 &aVal

TInt aLimit

Return value

TInt


Val()

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

Description

Parameters

TInt64 &aVal

const TInt64 &aLimit

Return value

TInt


Val()

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

Description

Parameters

TUint32 &aVal

TRadix aRadix

TUint aLimit

Return value

TInt


Val()

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

Description

Parameters

TInt64 &aVal

TRadix aRadix

const TInt64 &aLimit

Return value

TInt