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

Format Class Reference

Inheritance diagram for Format:

Styled List of all members.

Static Public Attributes

static ubyte DefaultStyle []

Static Protected Member Functions

static int print (inout Style style, TypeInfo[] arguments, void *argptr)
static int print (inout Style style, void *src, uint bytes, uint type)

Private Types

enum  Flags {
  Fill = 1, Left = Fill << 1, Prec = Left << 1, Hash = Prec << 1,
  Space = Hash << 1, Zero = Space << 1, Sign = Zero << 1, Comma = Sign << 1,
  Plus = Comma << 1, Array = Plus << 1
}

Static Private Member Functions

static void error (char[] msg)

Classes

struct  Sprintf

Detailed Description

Utility functions for styled, readable, output.

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.

See Styled.parse() for the list of format specifiers.

Definition at line 62 of file Format.d.


Member Enumeration Documentation

enum Flags [inherited]
 

Declare stylistic flags

Enumeration values:
Fill 
Left 
Prec 
Hash 
Space 
Zero 
Sign 
Comma 
Plus 
Array 

Definition at line 76 of file Styled.d.


Member Function Documentation

static int print inout Style  style,
TypeInfo[]  arguments,
void *  argptr
[inline, static, protected]
 

General purpose va_arg format routine, used by a number of classes and structs to emit printf() styled text.

This implementation simply converts its arguments into the appropriate internal type, and invokes the standard Mango type-formatter for each.

Note that this can handle type-arrays in addition to the usual char[] ~ e.g. one can print an array of integers just as easily as a single integer.

See Styled.parse() for the list of format specifiers.

Definition at line 147 of file Format.d.

References Styled::error().

Referenced by Format::Sprintf::format(), and DisplayWriter::print().

static int print inout Style  style,
void *  src,
uint  bytes,
uint  type
[inline, static, protected]
 

Convert various types into textual representation. This is used by DisplayWriter/PrintWriter, and by the various users of the variadic-argument functions.

See print() above, along with the DisplayWriter class.

Note that print() can handle type-arrays in addition to the usual char[]; e.g. one can print an array of integers just as easily as a single integer. To support this, a new style flag has been introduced to terminate the format string at the point of use. That is, the rest of the format string is considered to be part of the current format specifier, and will be repeated for each array element. For example, the format string " %@x," has a preceeding space, a trailing comma, and the array flag '@'. This will output an array of numeric values (char, byte, short, int, long, float, double, real, pointer) as a set of formatted hexadecimal strings.

See Styled.parse() for the list of format specifiers.

Definition at line 231 of file Format.d.

References DefaultStyle, and Styled::error().

static void error char[]  msg  )  [inline, static, inherited]
 

Throw an exception with the provided messsage

Definition at line 338 of file Styled.d.

Referenced by Number::format(), print(), and Format::Sprintf::utf8().


Member Data Documentation

ubyte DefaultStyle[] [static]
 

Initial value:

 [
                                      's', 'd', 'u', 'd', 'u', 
                                      'd', 'u', 'd', 'u', 'f', 
                                      'f', 'f', 's', 's', 's', 
                                      'x'
                                      ]
Default styles for supported types. This is used to format discrete values, or those provided without a specified format-string.

Definition at line 72 of file Format.d.

Referenced by print().


The documentation for this class was generated from the following file:
Generated on Fri Nov 11 18:44:35 2005 for Mango by  doxygen 1.4.0