Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <e32std.h>
Link against: euser.lib

Class TLex8

class TLex8;

Description

Provides general string-parsing functions suitable for numeric format conversions and syntactical-element parsing.

The class is the 8-bit variant for non-Unicode strings and 8-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 TLex8:

See also:


Construction and destruction


TLex8()

IMPORT_C TLex8();

Description

Default constructor.

Constructs a TLex8, initialising its members to NULL.


TLex8(const TUint8 *)

inline TLex8(const TUint8 *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 TUint8 *aString

String to be assigned.


TLex8(const TDesC8 &)

inline TLex8(const TDesC8 &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 TDesC8 &aDes

Descriptor to be assigned by reference.

[Top]


Member functions


operator=(const TUint8 *)

inline TLex8& operator=(const TUint8 *aString);

Description

Allows strings to be assigned to a TLex8.

Parameters

const TUint8 *aString

String to be assigned to the TLex8.

Return value

TLex8 &

TLex8 descriptor.


operator=(const TDesC8 &)

inline TLex8& operator=(const TDesC8 &aDes);

Description

Allows descriptors to be assigned to a TLex8.

Parameters

const TDesC8 &aDes

Descriptor to be assigned to the TLex8.

Return value

TLex8 &

TLex8 descriptor.


Eos()const

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(TLexMark8 &)const

inline void Mark(TLexMark8 &aMark) const;

Description

Sets the supplied extraction mark to the TLex8's next character position.

Parameters

TLexMark8 &aMark

On return, this is set to the next character position.


Mark()

inline void Mark();

Description

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


Inc()

IMPORT_C void Inc();

Description

Increments to the next character position.

Panic codes

USER

60, if the increment puts the next character position beyond the end of the string.


Inc(TInt)

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

60, 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()const

IMPORT_C TChar Peek() const;

Description

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

Return value

TChar

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

See also:


UnGet()

IMPORT_C void UnGet();

Description

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

Panic codes

USER

59, 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

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


UnGetToMark(const TLexMark8)

IMPORT_C void UnGetToMark(const TLexMark8 aMark);

Description

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

Parameters

const TLexMark8 aMark

Mark to copy to the next character position.

Panic codes

USER

63, 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(TInt)

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

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


SkipAndMark(TInt,TLexMark8 &)

IMPORT_C void SkipAndMark(TInt aNumber, TLexMark8 &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.

TLexMark8 &aMark

On return, set to the next character position.

Panic codes

USER

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


SkipSpaceAndMark()

inline void SkipSpaceAndMark();

Description

Moves the next character position past any white space and copies it to the TLex8's extraction mark.

Stops if at the end of the string.


SkipSpaceAndMark(TLexMark8 &)

IMPORT_C void SkipSpaceAndMark(TLexMark8 &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

TLexMark8 &aMark

On return, contains a reference to the next character position.


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

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(const TLexMark8)const

IMPORT_C TInt TokenLength(const TLexMark8 aMark) const;

Description

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

Parameters

const TLexMark8 aMark

Extraction mark indicating the start of the token.

Return value

TInt

Length of the token.

Panic codes

USER

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


MarkedToken()const

IMPORT_C TPtrC8 MarkedToken() const;

Description

Extracts the marked token.

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

Return value

TPtrC8

Extracted token.

Panic codes

USER

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


MarkedToken(const TLexMark8)const

IMPORT_C TPtrC8 MarkedToken(const TLexMark8 aMark) const;

Description

Extracts the token, starting at the specified mark

Parameters

const TLexMark8 aMark

Extraction mark indicating the start of the token.

Return value

TPtrC8

Extracted token.

Panic codes

USER

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


NextToken()

IMPORT_C TPtrC8 NextToken();

Description

Strips any white space and extracts the next token.

Return value

TPtrC8

Extracted token.


Remainder()const

IMPORT_C TPtrC8 Remainder() const;

Description

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

Return value

TPtrC8

Text from the next character position onwards.

Panic codes

USER

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


RemainderFromMark()const

IMPORT_C TPtrC8 RemainderFromMark() const;

Description

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

The function assumes that the current extraction mark is valid.

Return value

TPtrC8

Text from the extraction mark onwards.


RemainderFromMark(const TLexMark8)const

IMPORT_C TPtrC8 RemainderFromMark(const TLexMark8 aMark) const;

Description

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

Parameters

const TLexMark8 aMark

Extraction mark indicating where remaining text starts.

Return value

TPtrC8

Text from the specified extraction mark onwards.

Panic codes

USER

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

USER

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


Offset()const

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

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(const TLexMark8)const

IMPORT_C TInt MarkedOffset(const TLexMark8 aMark) const;

Description

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

Parameters

const TLexMark8 aMark

Extraction mark.

Return value

TInt

The offset of the extraction mark.

Panic codes

USER

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


Val(TInt8 &)

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(TInt16 &)

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(TInt32 &)

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(TInt64 &)

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(TInt &)

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(TUint8 &,TRadix)

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(TUint16 &,TRadix)

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(TUint32 &,TRadix)

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(TInt64 &,TRadix)

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(TUint &,TRadix)

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(TInt32 &,TInt)

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(TInt64 &,const TInt64 &)

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(TUint32 &,TRadix,TUint)

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(TInt64 &,TRadix,const TInt64 &)

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(TReal32 &)

IMPORT_C TInt Val(TReal32 &aVal);

Description

Parameters

TReal32 &aVal

Return value

TInt


Val(TReal32 &,TChar)

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

Description

Parameters

TReal32 &aVal

TChar aPoint

Return value

TInt


Val(TReal64 &)

IMPORT_C TInt Val(TReal64 &aVal);

Description

Parameters

TReal64 &aVal

Return value

TInt


Val(TReal64 &,TChar)

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

Description

Parameters

TReal64 &aVal

TChar aPoint

Return value

TInt


Assign(const TLex8 &)

inline void Assign(const TLex8 &aLex);

Description

Assigns a string to this object from another TLex8 object.

Parameters

const TLex8 &aLex

The object to be assigned.


Assign(const TUint8 *)

IMPORT_C void Assign(const TUint8 *aString);

Description

Assigns a string to this object from another string.

Parameters

const TUint8 *aString

A pointer to a string to be assigned.


Assign(const TDesC8 &)

IMPORT_C void Assign(const TDesC8 &aDes);

Description

Assigns a string to this object from a descriptor.

Parameters

const TDesC8 &aDes

The descriptor to be assigned.


Val(TInt32 &,TInt)

Interface status: deprecated Use BoundedVal(TInt32& aVal,TInt aLimit)

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

Description

Parameters

TInt32 &aVal

TInt aLimit

Return value

TInt


Val(TInt64 &,const TInt64 &)

Interface status: deprecated Use BoundedVal(TInt64& aVal,const TInt64& aLimit)

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

Description

Parameters

TInt64 &aVal

const TInt64 &aLimit

Return value

TInt


Val(TUint32 &,TRadix,TUint)

Interface status: deprecated Use BoundedVal(TUint32& aVal,TRadix aRadix,TUint aLimit)

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

Description

Parameters

TUint32 &aVal

TRadix aRadix

TUint aLimit

Return value

TInt


Val(TInt64 &,TRadix,const TInt64 &)

Interface status: deprecated Use BoundedVal(TInt64& aVal,TRadix aRadix,const TInt64& aLimit)

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

Description

Parameters

TInt64 &aVal

TRadix aRadix

const TInt64 &aLimit

Return value

TInt