Symbian
Symbian OS Library

SYMBIAN OS V9.3

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



Location: NumberConversion.h
Link against: numberconversion.lib

Class NumberConversion

class NumberConversion;

Description

Functions for converting numbers between different numbers form different scripts. The scripts supported are those given in enum TDigitType.

Members

Defined in NumberConversion:
AppendFormatNumber(), ConvertDigit(), ConvertDigits(), ConvertFirstNumber(), EMatchMultipleTypes, EMatchSingleTypeOnly, Format(), FormatDigit(), FormatNumber(), LengthOfConvertedText(), LengthOfFormattedNumber(), PositionAndTypeOfNextNumber(), TDigitMatchType


Member functions


ConvertFirstNumber()

static IMPORT_C TInt ConvertFirstNumber(const TDesC &aText, TInt &aLength, TDigitType &aDigitType, TDigitMatchType aDigitMatchType=EMatchMultipleTypes);

Description

Converts the descriptor aText into an integer and returns it. Ignores any minus signs: only non-negative numbers are returned.

Parameters

const TDesC &aText

Input text containing the integer to be converted.

TInt &aLength

On exit aLength is set to the number of characters converted from the descriptor.

TDigitType &aDigitType

Returns the digit type of the number converted. If no characters are matched, aDigitType will be set to EDigitTypeUnknown.

TDigitMatchType aDigitMatchType

If aDigitMatchType is set to EMatchMultipleTypes, different number types in the descriptor are matched and returned as a single number. In this case, aDigitType will be set to EDigitTypeAllTypes.

Return value

TInt

The (non-negative) number found.


PositionAndTypeOfNextNumber()

static IMPORT_C TInt PositionAndTypeOfNextNumber(const TDesC &aText, TDigitType &aDigitType, TInt aStartFrom=0);

Description

Finds the position and type of the next number in the descriptor. If the number has a preceeding minus sign, it will be ignored and the position of the first digit will be returned.

Parameters

const TDesC &aText

Text to be searched.

TDigitType &aDigitType

aDigitType is set to the digit type matched. If the descriptor doesn't contain a recognisable digit, aDigitType is set to EDigitTypeUnknown.

TInt aStartFrom

First position within aText to be searched.

Return value

TInt

The index of the first character.


FormatNumber()

static IMPORT_C void FormatNumber(TDes &aText, TInt aNumber, TDigitType aDigitType);

Pre-Condition

NumberConversion::LengthOfFormattedNumber(aNumber, aDigitType) <= aText.MaxLength() && 0 <= aNumber

Description

Converts a non-negative integer into localised text.

Parameters

TDes &aText

Output for the converted number. aText must be long enough to accommodate the text or the descriptor will panic. Negative numbers are not supported.

TInt aNumber

The number to be converted.

TDigitType aDigitType

The type of digit to render the number in.


FormatDigit()

static IMPORT_C void FormatDigit(TDes &aText, TInt aNumber, TInt aLeadingZero, TDigitType aDigitType);

Pre-Condition

NumberConversion::LengthOfFormattedNumber(aNumber, aDigitType) <= aText.MaxLength() && 0 <= aNumber

Description

Converts a non-negative integer into localised text.

Parameters

TDes &aText

Output for the converted number. aText must be long enough to accommodate the text or the descriptor will panic. Negative numbers are not supported.

TInt aNumber

The number to be converted.

TInt aLeadingZero

The number of zeros that appear before the number to be converted to localised text.

TDigitType aDigitType

The type of digit to render the number in.


AppendFormatNumber()

static IMPORT_C void AppendFormatNumber(TDes &aText, TInt aNumber, TDigitType aDigitType);

Pre-Condition

NumberConversion::LengthOfFormattedNumber(aNumber, aDigitType) <= aText.MaxLength() - aText.Length() && 0 <= aNumber

Description

Converts a non-negative integer into localised text, appending the result to a descriptor.

Parameters

TDes &aText

Output for the converted number. aText must have enough free space after its current length to accommodate the text or the descriptor will panic. Negative numbers are not supported.

TInt aNumber

The number to be converted.

TDigitType aDigitType

The type of digit to render the number in.


ConvertDigits()

static IMPORT_C void ConvertDigits(TDes &aText, TDigitType aDigitType);

Pre-Condition

NumberConversion::LengthOfConvertedText(aText, aDigitType) <= aText.MaxLength()

Description

Converts all of the digits in the descriptor aText into the format specified in aDigitType.

Post-Condition

All digits in the string will either conform to one of the constants defined in enum TDigitType or will match the digit type supplied in aDigitType.

Parameters

TDes &aText

The text that is to have its digits converted.

TDigitType aDigitType

The digit type to be converted to.


LengthOfFormattedNumber()

static IMPORT_C TInt LengthOfFormattedNumber(TInt aNumber, TDigitType aDigitType);

Description

Returns the number of characters required to format aNumber into text.

Parameters

TInt aNumber

The number to be converted.

TDigitType aDigitType

The format for the number.

Return value

TInt

The length of descriptor required to render the number as text.


LengthOfConvertedText()

static IMPORT_C TInt LengthOfConvertedText(const TDesC &aText, TDigitType aDigitType);

Description

Returns the length of the descriptor required to hold text with its digits converted.

Parameters

const TDesC &aText

Input text for the conversion.

TDigitType aDigitType

The type of digit that will be used for the conversion.

Return value

TInt

The length of descriptor that would be required to convert the digits in aText into the type specified by aDigitType.


Format()

static IMPORT_C void Format(TDigitType aDigitType, TRefByValue< TDes > aFmt,...);

Description

Formats the descriptor. Format specifiers are converted to values passed in the variable argument list. The following format specifiers are supported:

d - Interprets the argument as a TInt and formats it using the aDigitType format. Negative numbers are not supported.

S - Interprets the argument as a pointer to a TDesC and inserts it into the descriptor.

Parameters

TDigitType aDigitType

The digit type for all d directives.

TRefByValue< TDes > aFmt

...


ConvertDigit()

static IMPORT_C TChar ConvertDigit(TChar &aDigit, TDigitType aDigitType);

Description

converts aDigit (which could be arabic, western digit etc) into the form denoted by aDigitType.

Parameters

TChar &aDigit

TDigitType aDigitType

Return value

TChar

Digit into the form, denoted by aDigitType.

[Top]


Member enumerations


Enum TDigitMatchType

TDigitMatchType

Description

EMatchSingleTypeOnly

EMatchMultipleTypes