Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Int Class Reference

Inheritance diagram for Int:

Number List of all members.

Public Types

typedef Number format format

Static Public Member Functions

static int format (int i, inout Style style)
static char[] format (int i, NFormat fmt=NFormat.Decimal, Flags flags=0)
static int parse (char[] src, uint radix=10, uint *ate=null)

Private Types

enum  NFormat {
  Binary = 'b', Octal = 'o', Hex = 'x', HexUpper = 'X',
  Decimal = 'd', Unsigned = 'u'
}

Static Private Member Functions

static char[] format (char[] dst, long i, NFormat fmt=NFormat.Decimal, Flags flags=0)
static package uint trim (char[] digits, inout bool sign, uint *radix=null)

Detailed Description

A set of functions for converting between string and integer values. Additional methods are inherited via the super-class Number.

While these functions are all static, they are encapsulated within a class inheritance to preserve some namespace cohesion. One might use structs for encapsualtion instead, but then inheritance would be lost. Note that the root class, Styled, is abstract to prevent accidental instantiation of these classes.

Definition at line 57 of file Int.d.


Member Typedef Documentation

typedef Number format format
 

Definition at line 59 of file Int.d.


Member Enumeration Documentation

enum NFormat [inherited]
 

Enumeration values:
Binary 
Octal 
Hex 
HexUpper 
Decimal 
Unsigned 

Definition at line 58 of file Number.d.


Member Function Documentation

static int format int  i,
inout Style  style
[inline, static]
 

Format an integer based upon the Style provided. This is used by the Format class to convert integer values. See classes Styled & Format for more information.

Definition at line 69 of file Int.d.

static char [] format int  i,
NFormat  fmt = NFormat.Decimal,
Flags  flags = 0
[inline, static]
 

Convert an integer using the provided NFormat and flags.

The traditional printf() conversion specifiers are adhered to, and the following types are supported:

u - unsigned decimal d - signed decimal o - octal x - lowercase hexadecimal X - uppercase hexadecimal b - binary

Modifiers supported include:

# : prefix the conversion with a type identifier + : prefix positive decimals with a '+' space : prefix positive decimals with one space 0 : left-pad the number with zeros

These modifiers are specifed via the 'flags' provided, and are represented via these identifiers:

# : Flags.Hash + : Flags.Plus space : Flags.Space 0 : Flags.Zero

Definition at line 106 of file Int.d.

static int parse char[]  src,
uint  radix = 10,
uint *  ate = null
[inline, static]
 

Parse an integer value from the provided 'src' string. The 'radix' used defaults to 10, but can specified as desired. In particular, one should specify a radix of zero to parse that also (via a type specifier).

Definition at line 121 of file Int.d.

References Number::trim().

static char [] format char[]  dst,
long  i,
NFormat  fmt = NFormat.Decimal,
Flags  flags = 0
[inline, static, inherited]
 

Format numeric values into the provided output buffer. The traditional printf() conversion specifiers are adhered to, and the following types are supported:

u - unsigned decimal d - signed decimal o - octal x - lowercase hexadecimal X - uppercase hexadecimal b - binary

Modifiers supported include:

# : prefix the conversion with a type identifier + : prefix positive decimals with a '+' space : prefix positive decimals with one space 0 : left-pad the number with zeros

These modifiers are specifed via the 'flags' provided, and are represented via these identifiers:

# : Flags.Hash + : Flags.Plus space : Flags.Space 0 : Flags.Zero

Definition at line 90 of file Number.d.

References Styled::error().

static package uint trim char[]  digits,
inout bool  sign,
uint *  radix = null
[inline, static, inherited]
 

Strip leading whitespace, extract an optional numeric sign, and optionally strip and return a possible radix prefix.

This can be used as a precursor to the conversion of digits into a number.

Returns the number of matching characters.

Definition at line 197 of file Number.d.

Referenced by Long::parse(), parse(), and Double::parse().


The documentation for this class was generated from the following file:
Generated on Fri May 27 18:12:02 2005 for Mango by  doxygen 1.4.0