D Programming Language 2.0

- Comments
- D
- Search
- Home

Last update Sun Jan 20 11:39:26 2008

# std.metastrings

Templates with which to do compile time manipulation of strings.

template Format(A...)
  Formats constants into a string at compile time. Analogous to std.string.format().
  Parameters:
  A = tuple of constants, which can be strings, characters, or integral values.
  Formats:
  The formats supported are %s for strings, and %% for the % character.
  Example:

      import std.metastrings;
      import std.stdio;

      void main()
      {
        string s = Format!("Arg %s = %s", "foo", 27);
        writefln(s); // "Arg foo = 27"
      }

template ToString(ulong U)
template ToString(long I)
template ToString(uint U)
template ToString(int I)
template ToString(ushort U)
template ToString(short I)
template ToString(ubyte U)
template ToString(byte I)
template ToString(bool B)
template ToString(invariant(char)[] S)
template ToString(char C)
  Convert constant argument to a string.
template ParseUinteger(const(char)[] s)
  Parse unsigned integer literal from the start of string s.
  Returns:
  .value = the integer literal as a string, .rest = the string following the integer literal
  Otherwise:
  .value = null, .rest = s
template ParseInteger(const(char)[] s)
  Parse integer literal optionally preceded by '-' from the start of string s.
  Returns:
  .value = the integer literal as a string, .rest = the string following the integer literal
  Otherwise:
  .value = null, .rest = s

Public Domain | Page generated by Ddoc.