From c5dce1caf9fc8dff4e309683252fee5fbc0b6c2b Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 10 Dec 2012 11:06:55 -0800 Subject: [PATCH] Describe format string syntax. --- README.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.rst b/README.rst index 5a154c80..d034f31f 100644 --- a/README.rst +++ b/README.rst @@ -46,6 +46,23 @@ An object of any user-defined type for which there is an overloaded std::string s = str(fmt::Format("The date is {0}") << Date(2012, 12, 9)); // s == "The date is 2012-12-9" +Format string syntax +-------------------- + +A format string can contain "replacement fields" delimited by curly +braces ``{}``. Text outside of braces is copied unchanged to the output. +If you need to include a brace character in the literal text, it can be +escaped by doubling: ``{{`` and ``}}``. + +The grammar for a replacement field is as follows:: + + replacement_field: "{" arg_index [":" format_spec] "}" + arg_index: integer + format_spec: ["+"]["0"][width]["." precision][type] + width: integer + precision: integer + type: "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "o" | "s" | "x" | "X" + Motivation ----------