TLex16 Class Reference

#include <e32std.h>

class TLex16
Public Member Functions
TLex16()
TLex16(const TUint16 *)
TLex16(const TDesC16 &)
voidAssign(const TLex16 &)
IMPORT_C voidAssign(const TUint16 *)
IMPORT_C voidAssign(const TDesC16 &)
IMPORT_C TIntBoundedVal(TInt32 &, TInt)
IMPORT_C TIntBoundedVal(TInt64 &, const TInt64 &)
IMPORT_C TIntBoundedVal(TUint32 &, TRadix, TUint)
IMPORT_C TIntBoundedVal(TInt64 &, TRadix, const TInt64 &)
TBool Eos()
IMPORT_C TCharGet()
IMPORT_C voidInc()
IMPORT_C voidInc(TInt)
voidMark()
voidMark(TLexMark16 &)
TInt MarkedOffset()
IMPORT_C TIntMarkedOffset(const TLexMark16)
IMPORT_C TPtrC16MarkedToken()
IMPORT_C TPtrC16MarkedToken(const TLexMark16)
IMPORT_C TPtrC16NextToken()
IMPORT_C TIntOffset()
IMPORT_C TCharPeek()
IMPORT_C TPtrC16Remainder()
IMPORT_C TPtrC16RemainderFromMark()
IMPORT_C TPtrC16RemainderFromMark(const TLexMark16)
voidSkipAndMark(TInt)
IMPORT_C voidSkipAndMark(TInt, TLexMark16 &)
IMPORT_C voidSkipCharacters()
IMPORT_C voidSkipSpace()
IMPORT_C voidSkipSpaceAndMark(TLexMark16 &)
voidSkipSpaceAndMark()
TInt TokenLength()
IMPORT_C TIntTokenLength(const TLexMark16)
IMPORT_C voidUnGet()
voidUnGetToMark()
IMPORT_C voidUnGetToMark(const TLexMark16)
IMPORT_C TIntVal(TInt8 &)
IMPORT_C TIntVal(TInt16 &)
IMPORT_C TIntVal(TInt32 &)
IMPORT_C TIntVal(TInt64 &)
TInt Val(TInt &)
IMPORT_C TIntVal(TUint8 &, TRadix)
IMPORT_C TIntVal(TUint16 &, TRadix)
IMPORT_C TIntVal(TUint32 &, TRadix)
IMPORT_C TIntVal(TInt64 &, TRadix)
TInt Val(TUint &, TRadix)
IMPORT_C TIntVal(TReal32 &)
IMPORT_C TIntVal(TReal32 &, TChar)
IMPORT_C TIntVal(TReal64 &)
IMPORT_C TIntVal(TReal64 &, TChar)
TInt Val(TRealX &)
TInt Val(TRealX &, TChar)
TInt Val(TInt32 &, TInt)
TInt Val(TInt64 &, const TInt64 &)
TInt Val(TUint32 &, TRadix, TUint)
TInt Val(TInt64 &, TRadix, const TInt64 &)
void__DbgTest(TAny *)
void__DbgTestInvariant()
TLex16 &operator=(const TUint16 *)
TLex16 &operator=(const TDesC16 &)

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

See also: TLex

Constructor & Destructor Documentation

TLex16 ( )

IMPORT_CTLex16()

Default cosntructor.

Constructs a TLex16, initialising its members to NULL.

TLex16 ( const TUint16 * )

TLex16(const TUint16 *aString)[inline]

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
aStringString to be assigned.

TLex16 ( const TDesC16 & )

TLex16(const TDesC16 &aDes)[inline]

Constructs the object with a descriptor.

The extraction mark and next character members are initialised to point to the start of the string.

Parameters
aDesDescriptor to be assigned by reference.

Member Function Documentation

Assign ( const TLex16 & )

voidAssign(const TLex16 &aLex)[inline]

Assigns a string to this object from another TLex16 object.

Parameters
aLexThe object to be assigned.

Assign ( const TUint16 * )

IMPORT_C voidAssign(const TUint16 *aString)

Assigns a string to this object from another string.

Parameters
aStringA pointer to a string to be assigned.

Assign ( const TDesC16 & )

IMPORT_C voidAssign(const TDesC16 &aDes)

Assigns a string to this object from a descriptor.

Parameters
aDesThe descriptor to be assigned.

BoundedVal ( TInt32 &, TInt )

IMPORT_C TIntBoundedVal(TInt32 &aVal,
TIntaLimit
)

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

Parameters
aValOn return, contains the extracted integer.
aLimitThe upper limit.
Return Value
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 TIntBoundedVal(TInt64 &aVal,
const TInt64 &aLimit
)

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

Parameters
aValOn return, contains the extracted integer.
aLimitThe upper limit.
Return Value
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 TIntBoundedVal(TUint32 &aVal,
TRadixaRadix,
TUintaLimit
)

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
aValOn return, contains the extracted integer.
aRadixThe radix to use when converting the number.
aLimitThe upper limit.
Return Value
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 TIntBoundedVal(TInt64 &aVal,
TRadixaRadix,
const TInt64 &aLimit
)

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
aValOn return, contains the extracted integer.
aRadixThe radix to use when converting the number.
aLimitThe upper limit.
Return Value
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.

Eos ( )

TBool Eos()const [inline]

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

Return Value
True if at end of string, false otherwise.

Get ( )

IMPORT_C TCharGet()

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

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

Inc ( )

IMPORT_C voidInc()

Increments to the next character position.

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

Inc ( TInt )

IMPORT_C voidInc(TIntaNumber)

Increments the next character position by aNumber.

Parameters
aNumberThe number of characters to increment the next character position by.
Panic Codes
USER65, if the increment puts the next character position before the start or beyond the end of the string.

Mark ( )

voidMark()[inline]

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

Mark ( TLexMark16 & )

voidMark(TLexMark16 &aMark)const [inline]

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

Parameters
aMarkOn return, set to the next character position.

MarkedOffset ( )

TInt MarkedOffset()const [inline]

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

Return Value
The offset of the extraction mark.

MarkedOffset ( const TLexMark16 )

IMPORT_C TIntMarkedOffset(const TLexMark16aMark)const

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

Parameters
aMarkExtraction mark.
Return Value
The offset of the extraction mark.
Panic Codes
USER68, if the specified mark is before the start or beyond the end of the string.

MarkedToken ( )

IMPORT_C TPtrC16MarkedToken()const

Extracts the marked token.

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

Return Value
Extracted token.
Panic Codes
USER68, if the specified mark is before the start or beyond the end of the string.

MarkedToken ( const TLexMark16 )

IMPORT_C TPtrC16MarkedToken(const TLexMark16aMark)const

Extracts the token, starting at the specified mark

Parameters
aMarkExtraction mark indicating the start of the token.
Return Value
Extracted token.
Panic Codes
USER68, if the specified mark is before the start or beyond the end of the string.

NextToken ( )

IMPORT_C TPtrC16NextToken()

Strips any white space and extracts the next token.

Return Value
Extracted token.

Offset ( )

IMPORT_C TIntOffset()const

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

Return Value
Offset of next character position.

Peek ( )

IMPORT_C TCharPeek()const

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

See also: TLex16::Get

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

Remainder ( )

IMPORT_C TPtrC16Remainder()const

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

Return Value
Text from the next character position onwards.
Panic Codes
USER17, if the value of (next character position - extraction mark) is negative.

RemainderFromMark ( )

IMPORT_C TPtrC16RemainderFromMark()const

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
Text from the extraction mark onwards.

RemainderFromMark ( const TLexMark16 )

IMPORT_C TPtrC16RemainderFromMark(const TLexMark16aMark)const

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

Parameters
aMarkExtraction mark indicating where remaining text starts.
Return Value
Text from the specified extraction mark onwards.
Panic Codes
USER17, if the value of (next character position - extraction mark) is negative.
USER68, if the specified mark is before the start or beyond the end of the string.

SkipAndMark ( TInt )

voidSkipAndMark(TIntaNumber)[inline]

Moves the next character position a specified number of characters.

Parameters
aNumberNumber of characters to skip.
Panic Codes
USER68, if the skip moves the next character position either to before the start or beyond the end of the string.

SkipAndMark ( TInt, TLexMark16 & )

IMPORT_C voidSkipAndMark(TIntaNumber,
TLexMark16 &aMark
)

Moves the next character position a specified number of characters and copies it to the specified extraction mark.

Parameters
aNumberNumber of characters to skip.
aMarkOn return, set to the next character position.
Panic Codes
USER66, if the skip moves the next character position either to before the start or beyond the end of the string.

SkipCharacters ( )

IMPORT_C voidSkipCharacters()

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

Stops if at the end of the string.

SkipSpace ( )

IMPORT_C voidSkipSpace()

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

Stops if at the end of string.

SkipSpaceAndMark ( TLexMark16 & )

IMPORT_C voidSkipSpaceAndMark(TLexMark16 &aMark)

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
aMarkOn return, contains a reference to the next character position.

SkipSpaceAndMark ( )

voidSkipSpaceAndMark()[inline]

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.

TokenLength ( )

TInt TokenLength()const [inline]

Gets the length of the token.

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

Return Value
Length of the token.

TokenLength ( const TLexMark16 )

IMPORT_C TIntTokenLength(const TLexMark16aMark)const

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

Parameters
aMarkExtraction mark indicating the start of the token.
Return Value
Length of the token.
Panic Codes
USER68, if the specified mark is before the start or beyond the end of the string.

UnGet ( )

IMPORT_C voidUnGet()

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

Panic Codes
USER64, if the previous character is before the start of the string.

UnGetToMark ( )

voidUnGetToMark()[inline]

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

Panic Codes
USER68, if the specified mark is before the start or beyond the end of the string.

UnGetToMark ( const TLexMark16 )

IMPORT_C voidUnGetToMark(const TLexMark16aMark)

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

Parameters
aMarkMark to copy to the next character position.
Panic Codes
USER68, if the extraction mark is before the start or beyond the end of the string.

Val ( TInt8 & )

IMPORT_C TIntVal(TInt8 &aVal)

Parses the string to extract a signed 8-bit integer.

Parameters
aValOn return, contains the extracted integer.
Return Value
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 TIntVal(TInt16 &aVal)

Parses the string to extract a signed 16-bit integer.

Parameters
aValOn return, contains the extracted integer.
Return Value
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 TIntVal(TInt32 &aVal)

Parses the string to extract a signed 32-bit integer.

Parameters
aValOn return, contains the extracted integer.
Return Value
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 TIntVal(TInt64 &aVal)

Parses the string to extract a signed 64-bit integer.

Parameters
aValOn return, contains the extracted integer.
Return Value
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 & )

TInt Val(TInt &aVal)[inline]

Parses the string to extract a signed integer.

Parameters
aValOn return, contains the extracted integer.
Return Value
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 TIntVal(TUint8 &aVal,
TRadixaRadix
)

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
aValOn return, contains the extracted integer.
aRadixThe radix to use when converting the number.
Return Value
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 TIntVal(TUint16 &aVal,
TRadixaRadix
)

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
aValOn return, contains the extracted integer.
aRadixThe radix to use when converting the number.
Return Value
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 TIntVal(TUint32 &aVal,
TRadixaRadix
)

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
aValOn return, contains the extracted integer.
aRadixThe radix to use when converting the number.
Return Value
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 TIntVal(TInt64 &aVal,
TRadixaRadix
)

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
aValOn return, contains the extracted integer.
aRadixThe radix to use when converting the number.
Return Value
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 )

TInt Val(TUint &aVal,
TRadixaRadix = EDecimal
)[inline]

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

Parameters
aValOn return, contains the extracted integer.
aRadixThe radix to use when converting the number. The default radix for this function overload is decimal.
Return Value
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 TIntVal(TReal32 &aVal)

Val ( TReal32 &, TChar )

IMPORT_C TIntVal(TReal32 &aVal,
TCharaPoint
)

Val ( TReal64 & )

IMPORT_C TIntVal(TReal64 &aVal)

Val ( TReal64 &, TChar )

IMPORT_C TIntVal(TReal64 &aVal,
TCharaPoint
)

Val ( TRealX & )

TInt Val(TRealX &aVal)

Val ( TRealX &, TChar )

TInt Val(TRealX &aVal,
TCharaPoint
)

Val ( TInt32 &, TInt )

TInt Val(TInt32 &aVal,
TIntaLimit
)[inline]

Val ( TInt64 &, const TInt64 & )

TInt Val(TInt64 &aVal,
const TInt64 &aLimit
)[inline]

Val ( TUint32 &, TRadix, TUint )

TInt Val(TUint32 &aVal,
TRadixaRadix,
TUintaLimit
)[inline]

Val ( TInt64 &, TRadix, const TInt64 & )

TInt Val(TInt64 &aVal,
TRadixaRadix,
const TInt64 &aLimit
)[inline]

__DbgTest ( TAny * )

void__DbgTest(TAny *aPtr)const

__DbgTestInvariant ( )

void__DbgTestInvariant()const

operator= ( const TUint16 * )

TLex16 &operator=(const TUint16 *aString)[inline]

Allows strings to be assigned to a TLex16.

Parameters
aStringString to be assigned to the TLex16.
Return Value
TLex16 descriptor.

operator= ( const TDesC16 & )

TLex16 &operator=(const TDesC16 &aDes)[inline]

Allows descriptors to be assigned to a TLex16.

Parameters
aDesDescriptor to be assigned to the TLex16.
Return Value
TLex8 descriptor.