Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <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:


Member functions


ConvertFirstNumber(const TDesC &,TInt &,TDigitType &,TDigitMatchType)

IMPORT_C static 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 TDesC16 &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.

NumberConversion::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(const TDesC &,TDigitType &,TInt)

IMPORT_C static 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 TDesC16 &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(TDes &,TInt,TDigitType)

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

TDes16 &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(TDes &,TInt,TInt,TDigitType)

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

TDes16 &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(TDes &,TInt,TDigitType)

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

TDes16 &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(TDes &,TDigitType)

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

TDes16 &aText

The text that is to have its digits converted.

TDigitType aDigitType

The digit type to be converted to.


LengthOfFormattedNumber(TInt,TDigitType)

IMPORT_C static 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(const TDesC &,TDigitType)

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

Description

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

Parameters

const TDesC16 &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(TDigitType,TRefByValue< TDes >,...)

IMPORT_C static 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< TDes16 > aFmt

...


ConvertDigit(TChar &,TDigitType)

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