From 94d387cd4526c3d3179098bf2ae60d653aac07d8 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 19 Aug 2016 21:41:19 -0700 Subject: [PATCH] Update paper --- doc/Text Formatting.html | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/doc/Text Formatting.html b/doc/Text Formatting.html index e8feaa88..0d0027d4 100644 --- a/doc/Text Formatting.html +++ b/doc/Text Formatting.html @@ -64,6 +64,7 @@ Victor Zverovich, victor.zverovich@gmail.com     Format String Syntax
    Extensibility
    Locale Support
+    Positional Arguments
Wording
References

@@ -119,7 +120,7 @@ syntax.

Therefore we propose a new syntax based on the ones used in Python [3], the .NET family of languages [4], -and Rust [5]. This syntax uses '{' and +and Rust [5]. This syntax employs '{' and '}' as replacement field delimiters instead of '%' and it is described in details in TODO:link. Here are some of the advantages:

@@ -149,6 +150,8 @@ and the new syntax is given in the following table. -<left alignment ++ spacespace +## +00 hhunused hunused lunused @@ -191,13 +194,28 @@ which simplifies migration from printf. Notable difference is in the alignment specification. The proposed syntax allows left, center, and right alignment represented by '<', '^', and '>' respectively which is more expressive than the corresponding -printf syntax. +printf syntax. The latter only supports left and right (the default) +alignment. +

+ +

+The following example uses center alignment and '*' as a fill +character: +

+ +
+std::format("{:*^30}", "centered");
+
+ +

+resulting in "***********centered***********". +The same formatting cannot be easily achieved with printf.

Extensibility

-Both format string syntax and API are designed with extensibility in mind. +Both the format string syntax and the API are designed with extensibility in mind. The mini-language can be extended for user-defined types and users can provide functions that do parsing and formatting for such types.

@@ -215,14 +233,25 @@ functions that do parsing and formatting for such types.

where format-spec is predefined for built-in types, but can be -customized for user-defined types. For example, time formatting +customized for user-defined types. For example, the syntax can be extended +for put_time-like date and time formatting: +

-TODO: elaborate

+
+std::time_t t = std::time(nullptr);
+std::string date = std::format("The date is {0:%Y-%m-%d}.", *std::localtime(&t));
+
+ +

TODO: API

Locale Support

TODO

+

Positional Arguments

+ +

TODO

+

Wording

TODO