License:
BSD style: see license.txt

Version:
Initial release: 2005

author:
Kris, Keinfarbton

This module provides a general-purpose formatting system to convert values to text suitable for display. There is support for alignment, justification, and common format specifiers for numbers.

Layout can be customized via configuring various handlers and associated meta-date. This is utilized to plug in text.locale for handling custom formats, date/time and culture-specific conversions.

The format notation is influenced by that used by the .NET and ICU frameworks, rather than C-style printf or D-style writef notation.

  • alias Arg ;
  • Platform issues ...

  • alias ArgList ;
  • Platform issues ...

  • class Layout (T);
  • Contains methods for replacing format items in a string with string equivalents of each argument.

  • T[] sprint (T[] result, T[] formatStr,...);


  • T[] vprint (T[] result, T[] formatStr, TypeInfo[] arguments, ArgList args);


  • T[] convert (T[] formatStr,...);
  • Replaces the format item in a string with the string equivalent of each argument.

    Params:
    T[] formatStr A string containing format items.
    args A list of arguments.

    Returns:
    A copy of formatStr in which the items have been replaced by the string equivalent of the arguments.

    Remarks:
    The formatStr parameter is embedded with format items of the form:

    {index[,alignment][:format-string]}

    • index
      An integer indicating the element in a list to format.
    • alignment
      An optional integer indicating the minimum width. The result is padded with spaces if the length of the value is less than alignment.
    • format-string
      An optional string of formatting codes.



    The leading and trailing braces are required. To include a literal brace character, use two leading or trailing brace characters.

    If formatStr is "{0} bottles of beer on the wall" and the argument is an int with the value of 99, the return value will be:
    "99 bottles of beer on the wall".



  • uint convert (Sink sink, T[] formatStr,...);


  • T[] convert (TypeInfo[] arguments, ArgList args, T[] formatStr);


  • T[] convertOne (T[] result, TypeInfo ti, Arg arg);


  • uint convert (Sink sink, TypeInfo[] arguments, ArgList args, T[] formatStr);


  • uint parse (T[] layout, TypeInfo[] ti, Arg[] args, Sink sink);
  • Parse the format-string, emitting formatted args and text fragments as we go.

  • void error (char[] msg);


  • uint spaces (Sink sink, int count);


  • T[] munge (T[] result, T[] format, TypeInfo type, Arg p);


  • T[] unknown (T[] result, T[] format, TypeInfo type, Arg p);


  • T[] integer (T[] output, long v, T[] format, ulong mask = (ulong).max, T[] def = "d");


  • T[] floater (T[] output, real v, T[] format);


  • bool parseGeneric (T[] format, ref uint width, ref T style);


  • enum TypeCode ;


  • Copyright (c) 2005 Kris. All rights reserved :: page rendered by CandyDoc