Module richstring

Search:
Group by:

Module provides string utilities

Macros

macro fmt*(fmt: static[string]): expr
String interpolation macro with scala-like format specifiers. Knows about:
  • d - decimal number formatter
  • h - hex number formatter
  • f - float number formatter
  • e - float number formatter (scientific form)
  • s - string formatter

Examples:

import boost.richstring

let s = "string"
assert fmt"${s[0..2].toUpper}" == "STR"
assert fmt"${-10}%04d" == "-010"
assert fmt"0x${10}%02x" == "0x0A"
assert fmt"""${"test"}%-5s""" == "test "
assert fmt"${1}%.3f" == "1.000"
assert fmt"Hello, $s!" == "Hello, string!"
  Source Edit