Symbian
Symbian OS Library

SYMBIAN OS V9.3

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



Location: 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:
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(), TLex8(), TLex8(), TLex8(), 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


TLex8()

IMPORT_C TLex8();

Description

Default constructor.

Constructs a TLex8, initialising its members to NULL.


TLex8()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 TLex8 &aLex);

Description

Assigns a string to this object from another TLex8 object.

Parameters

const TLex8 &aLex

The object to be assigned.


Assign()

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

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

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