Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
94d387cd
Commit
94d387cd
authored
Aug 19, 2016
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update paper
parent
721c9100
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
5 deletions
+34
-5
doc/Text Formatting.html
doc/Text Formatting.html
+34
-5
No files found.
doc/Text Formatting.html
View file @
94d387cd
...
@@ -64,6 +64,7 @@ Victor Zverovich, victor.zverovich@gmail.com
...
@@ -64,6 +64,7 @@ Victor Zverovich, victor.zverovich@gmail.com
<a
href=
"#Syntax"
>
Format String Syntax
</a><br>
<a
href=
"#Syntax"
>
Format String Syntax
</a><br>
<a
href=
"#Extensibility"
>
Extensibility
</a><br>
<a
href=
"#Extensibility"
>
Extensibility
</a><br>
<a
href=
"#Locale"
>
Locale Support
</a><br>
<a
href=
"#Locale"
>
Locale Support
</a><br>
<a
href=
"#PosArguments"
>
Positional Arguments
</a><br>
<a
href=
"#Wording"
>
Wording
</a><br>
<a
href=
"#Wording"
>
Wording
</a><br>
<a
href=
"#References"
>
References
</a><br>
<a
href=
"#References"
>
References
</a><br>
</p>
</p>
...
@@ -119,7 +120,7 @@ syntax.
...
@@ -119,7 +120,7 @@ syntax.
</p>
</p>
Therefore we propose a new syntax based on the ones used in Python
Therefore we propose a new syntax based on the ones used in Python
<a
href=
"#3"
>
[3]
</a>
, the .NET family of languages
<a
href=
"#4"
>
[4]
</a>
,
<a
href=
"#3"
>
[3]
</a>
, the .NET family of languages
<a
href=
"#4"
>
[4]
</a>
,
and Rust
<a
href=
"#5"
>
[5]
</a>
. This syntax
use
s
<code>
'{'
</code>
and
and Rust
<a
href=
"#5"
>
[5]
</a>
. This syntax
employ
s
<code>
'{'
</code>
and
<code>
'}'
</code>
as replacement field delimiters instead of
<code>
'%'
</code>
<code>
'}'
</code>
as replacement field delimiters instead of
<code>
'%'
</code>
and it is described in details in TODO:link. Here are some of the advantages:
and it is described in details in TODO:link. Here are some of the advantages:
</p>
</p>
...
@@ -149,6 +150,8 @@ and the new syntax is given in the following table.
...
@@ -149,6 +150,8 @@ and the new syntax is given in the following table.
<tr><td>
-
</td><td>
<
</td><td>
left alignment
</td></tr>
<tr><td>
-
</td><td>
<
</td><td>
left alignment
</td></tr>
<tr><td>
+
</td><td>
+
</td><td></td></tr>
<tr><td>
+
</td><td>
+
</td><td></td></tr>
<tr><td><em>
space
</em></td><td><em>
space
</em></td><td></td></tr>
<tr><td><em>
space
</em></td><td><em>
space
</em></td><td></td></tr>
<tr><td>
#
</td><td>
#
</td><td></td></tr>
<tr><td>
0
</td><td>
0
</td><td></td></tr>
<tr><td>
hh
</td><td>
unused
</td><td></td></tr>
<tr><td>
hh
</td><td>
unused
</td><td></td></tr>
<tr><td>
h
</td><td>
unused
</td><td></td></tr>
<tr><td>
h
</td><td>
unused
</td><td></td></tr>
<tr><td>
l
</td><td>
unused
</td><td></td></tr>
<tr><td>
l
</td><td>
unused
</td><td></td></tr>
...
@@ -191,13 +194,28 @@ which simplifies migration from <code>printf</code>. Notable difference is in
...
@@ -191,13 +194,28 @@ which simplifies migration from <code>printf</code>. Notable difference is in
the alignment specification. The proposed syntax allows left, center, and right
the alignment specification. The proposed syntax allows left, center, and right
alignment represented by
<code>
'
<
'
</code>
,
<code>
'^'
</code>
, and
alignment represented by
<code>
'
<
'
</code>
,
<code>
'^'
</code>
, and
<code>
'
>
'
</code>
respectively which is more expressive than the corresponding
<code>
'
>
'
</code>
respectively which is more expressive than the corresponding
<code>
printf
</code>
syntax.
<code>
printf
</code>
syntax. The latter only supports left and right (the default)
alignment.
</p>
<p>
The following example uses center alignment and
<code>
'*'
</code>
as a fill
character:
</p>
<pre
class=
"example"
>
<code>
std::format("{:*^30}", "centered");
</code>
</pre>
<p>
resulting in
<code>
"***********centered***********"
</code>
.
The same formatting cannot be easily achieved with
<code>
printf
</code>
.
</p>
</p>
<h3><a
name=
"Extensibility"
>
Extensibility
</a></h3>
<h3><a
name=
"Extensibility"
>
Extensibility
</a></h3>
<p>
<p>
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
The mini-language can be extended for user-defined types and users can provide
functions that do parsing and formatting for such types.
functions that do parsing and formatting for such types.
</p>
</p>
...
@@ -215,14 +233,25 @@ functions that do parsing and formatting for such types.
...
@@ -215,14 +233,25 @@ functions that do parsing and formatting for such types.
<p>
<p>
where
<em>
format-spec
</em>
is predefined for built-in types, but can be
where
<em>
format-spec
</em>
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
<code>
put_time
</code>
-like date and time formatting:
</p>
<pre
class=
"example"
>
<code>
std::time_t t = std::time(nullptr);
std::string date = std::format("The date is {0:%Y-%m-%d}.", *std::localtime(
&t));
</code>
</pre>
TODO: elaborate
</p>
<p>
TODO: API
</p>
<h3><a
name=
"Locale"
>
Locale Support
</a></h3>
<h3><a
name=
"Locale"
>
Locale Support
</a></h3>
<p>
TODO
</p>
<p>
TODO
</p>
<h3><a
name=
"PosArguments"
>
Positional Arguments
</a></h3>
<p>
TODO
</p>
<h2><a
name=
"Wording"
>
Wording
</a></h2>
<h2><a
name=
"Wording"
>
Wording
</a></h2>
<p>
TODO
</p>
<p>
TODO
</p>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment