std.metastrings - D Programming Language - Digital Mars

D Programming Language 2.0

- Comments
- D
- Search
- Home

Last update Wed Sep 2 00:11:55 2009

# std.metastrings

Templates with which to do compile-time manipulation of strings.

Authors:
Walter Bright, Don Clugston

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 toStringNow(ulong v)
template toStringNow(long v)
template toStringNow(uint U)
template toStringNow(int I)
template toStringNow(bool B)
template toStringNow(string S)
template toStringNow(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

deprecated alias ToString;
deprecated alias ParseUinteger;
deprecated alias ParseInteger;
  Deprecated aliases held for backward compatibility.

Public Domain | Page generated by Ddoc.