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

Format.d File Reference

Go to the source code of this file.

Functions

struct FormatStructTemplate (T)
typedef FormatStructTemplate (char) FormatStruct
class FormatClassTemplate (T)
typedef FormatClassTemplate (char) Format

Variables

module mango convert Format
import std stdarg
import mango convert Type
import mango convert mango
convert 
Integer


Detailed Description

Copyright (c) 2004 Kris Bell

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for damages of any kind arising from the use of this software.

Permission is hereby granted to anyone to use this software for any purpose, including commercial applications, and to alter it and/or redistribute it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment within documentation of said product would be appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

3. This notice may not be removed or altered from any distribution of the source.

4. Derivative works are permitted, but they must carry this notice in full and credit the original source.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Version:
Initial version; Nov 2005
Author:
Kris

Definition in file Format.d.


Function Documentation

struct FormatStructTemplate  ) 
 

Functions for styled, readable, output. See parse() for the list of format specifiers.

Default styles for supported styles. This is used to format discrete values, or those provided without a specified format-string.

Configure this Format with an output handler, a workspace area, and a floating point handler. The latter is optional.

Throw an error

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 style, and invokes the standard Mango style-formatter for each.

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

See parse() for the list of format specifiers.

Emit a single formatted argument. Format may be null

Emit a single formatted argument.

Note that emit() 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 parse() for the list of format specifiers.

internal method to map data styles

Clear the current state. This is typically used internally only.

Emit some spaces. This was originally an inner method, but that caused the code size to inexplicably increase by a large amount. A regular private function does not have that effect.

Emit a field, surrounded by optional prefix and postfix strings, and optionally padded with spaces.

Emit an integer field

Emit a floating-point field

test for a digit

Parse a format specifier into its constituent flags and values. Syntax follows the traditional printf() approach, as follows:

[flags][width][.precision]style

Where 'style' is one of:

s : string format c : character format d : signed format u : unsigned format x : hexadecimal format X : uppercase hexadecimal format e : scientific notation f : floating point format g : 'e' or 'f', based upon width

Note that there are no variants on the format styles ~ long, int, short, and byte differences are all handled internally.

The 'flags' supported:

space : prefix negative integer with one space; pad any style when combined with a width specifier

  • : left-align fields padded with spaces + : prefix positive integer with one '+' 0 : prefix integers with zeroes; requires a width specification # : prefix integers with a style specifier @ : Array specifier

The 'width' should be specified for either zero or space padding, and may be used with all formatting styles.

A 'precision' can be used to stipulate the number of decimal-places, or a slice of a text string.

Note that the Format package supports array-output in addition to the usual printf() output.

Definition at line 55 of file Format.d.

References FormatStructTemplate(), Integer, IntegerTemplate(), and type().

Referenced by FormatClassTemplate(), FormatStructTemplate(), and MutableStringTemplate().

typedef FormatStructTemplate char   ) 
 

Functions for styled, readable, output. See Format.parse() for the list of format specifiers.

class FormatClassTemplate  ) 
 

Definition at line 666 of file Format.d.

References Format, FormatClassTemplate(), and FormatStructTemplate().

Referenced by BufferFormatTemplate(), and FormatClassTemplate().

typedef FormatClassTemplate char   ) 
 


Variable Documentation

module mango convert Format
 

Definition at line 40 of file Format.d.

import std stdarg
 

Definition at line 42 of file Format.d.

import mango convert Type
 

Definition at line 44 of file Format.d.

import mango convert mango convert Integer
 

Definition at line 44 of file Format.d.


Generated on Sat Dec 24 17:28:35 2005 for Mango by  doxygen 1.4.0