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
9cbb25e4
Commit
9cbb25e4
authored
Nov 05, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify markup
parent
10698cc4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
34 deletions
+34
-34
README.rst
README.rst
+34
-34
No files found.
README.rst
View file @
9cbb25e4
...
@@ -24,12 +24,12 @@ Features
...
@@ -24,12 +24,12 @@ Features
* Write API similar to the one used by IOStreams but much faster and more
* Write API similar to the one used by IOStreams but much faster and more
consistent.
consistent.
* Format API with `format string syntax
* Format API with `format string syntax
<http://cppformat.readthedocs.org/en/latest/#format-string-syntax>`_
_
<http://cppformat.readthedocs.org/en/latest/#format-string-syntax>`_
similar to the one used by `str.format
similar to the one used by `str.format
<http://docs.python.org/2/library/stdtypes.html#str.format>`_
_
in Python.
<http://docs.python.org/2/library/stdtypes.html#str.format>`_ in Python.
* Support for user-defined types.
* Support for user-defined types.
* High speed: performance of the format API is close to that of
* High speed: performance of the format API is close to that of
glibc's `printf <http://en.cppreference.com/w/cpp/io/c/fprintf>`_
_
glibc's `printf <http://en.cppreference.com/w/cpp/io/c/fprintf>`_
and better than performance of IOStreams. See `Speed tests`_ and
and better than performance of IOStreams. See `Speed tests`_ and
`Fast integer to string conversion in C++
`Fast integer to string conversion in C++
<http://zverovich.net/2013/09/07/integer-to-string-conversion-in-cplusplus.html>`_.
<http://zverovich.net/2013/09/07/integer-to-string-conversion-in-cplusplus.html>`_.
...
@@ -37,19 +37,19 @@ Features
...
@@ -37,19 +37,19 @@ Features
header file and a single source file) and compiled code.
header file and a single source file) and compiled code.
See `Compile time and code bloat`_.
See `Compile time and code bloat`_.
* Reliability: the library has an extensive set of `unit tests
* Reliability: the library has an extensive set of `unit tests
<https://github.com/cppformat/cppformat/tree/master/test>`_
_
.
<https://github.com/cppformat/cppformat/tree/master/test>`_.
* Safety: the library is fully type safe, errors in format strings are
* Safety: the library is fully type safe, errors in format strings are
reported using exceptions, automatic memory management prevents buffer
reported using exceptions, automatic memory management prevents buffer
overflow errors.
overflow errors.
* Ease of use: small self-contained code base, no external dependencies,
* Ease of use: small self-contained code base, no external dependencies,
permissive BSD `license`_.
permissive BSD `license`_.
* `Portability <http://cppformat.github.io#portability>`_
_
with consistent output
* `Portability <http://cppformat.github.io#portability>`_ with consistent output
across platforms and support for older compilers.
across platforms and support for older compilers.
* Clean warning-free codebase even on high warning levels
* Clean warning-free codebase even on high warning levels
(-Wall -Wextra -pedantic).
(-Wall -Wextra -pedantic).
* Support for wide strings.
* Support for wide strings.
See the `documentation <http://cppformat.readthedocs.org/en/latest/>`_
_
for more details.
See the `documentation <http://cppformat.readthedocs.org/en/latest/>`_ for more details.
Examples
Examples
--------
--------
...
@@ -96,10 +96,10 @@ An object of any user-defined type for which there is an overloaded
...
@@ -96,10 +96,10 @@ An object of any user-defined type for which there is an overloaded
// s == "The date is 2012-12-9"
// s == "The date is 2012-12-9"
You can use the `FMT_VARIADIC
You can use the `FMT_VARIADIC
<http://cppformat.readthedocs.org/en/latest/#project0format_8h_1a65215c7dfcc0e942cd0798860877e86b>`_
_
<http://cppformat.readthedocs.org/en/latest/#project0format_8h_1a65215c7dfcc0e942cd0798860877e86b>`_
macro to create your own functions similar to `format
macro to create your own functions similar to `format
<http://cppformat.github.io/doc/latest#fmt::format__StringRef.ArgListCR>`_
_
and
<http://cppformat.github.io/doc/latest#fmt::format__StringRef.ArgListCR>`_ and
`print <http://cppformat.readthedocs.org/en/latest#fmt::print__StringRef.ArgListCR>`_
_
`print <http://cppformat.readthedocs.org/en/latest#fmt::print__StringRef.ArgListCR>`_
which take arbitrary arguments:
which take arbitrary arguments:
.. code-block:: c++
.. code-block:: c++
...
@@ -154,10 +154,10 @@ Printf
...
@@ -154,10 +154,10 @@ Printf
The good thing about printf is that it is very fast and readily available
The good thing about printf is that it is very fast and readily available
being a part of the C standard library. The main drawback is that it
being a part of the C standard library. The main drawback is that it
doesn't support user-defined types. Printf also has safety issues although
doesn't support user-defined types. Printf also has safety issues although
they are mostly solved with `_
_
attribute__ ((format (printf, ...))
they are mostly solved with `_attribute__ ((format (printf, ...))
<http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`_
_
in GCC.
<http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`_ in GCC.
There is a POSIX extension that adds positional arguments required for
There is a POSIX extension that adds positional arguments required for
`i18n <http://en.wikipedia.org/wiki/Internationalization_and_localization>`_
_
`i18n <http://en.wikipedia.org/wiki/Internationalization_and_localization>`_
to printf but it is not a part of C99 and may not be available on some
to printf but it is not a part of C99 and may not be available on some
platforms.
platforms.
...
@@ -233,7 +233,7 @@ for completeness. As IOStreams it suffers from the problem of mixing
...
@@ -233,7 +233,7 @@ for completeness. As IOStreams it suffers from the problem of mixing
verbatim text with arguments. The library is pretty fast, but slower
verbatim text with arguments. The library is pretty fast, but slower
on integer formatting than ``fmt::Writer`` on Karma's own benchmark,
on integer formatting than ``fmt::Writer`` on Karma's own benchmark,
see `Fast integer to string conversion in C++
see `Fast integer to string conversion in C++
<http://zverovich.net/2013/09/07/integer-to-string-conversion-in-cplusplus.html>`_
_
.
<http://zverovich.net/2013/09/07/integer-to-string-conversion-in-cplusplus.html>`_.
Benchmarks
Benchmarks
----------
----------
...
@@ -247,7 +247,7 @@ The following speed tests results were generated by building
...
@@ -247,7 +247,7 @@ The following speed tests results were generated by building
runs. In the test, the format string ``"%0.10f:%04d:%+g:%s:%p:%c:%%\n"`` or
runs. In the test, the format string ``"%0.10f:%04d:%+g:%s:%p:%c:%%\n"`` or
equivalent is filled 2000000 times with output sent to ``/dev/null``; for
equivalent is filled 2000000 times with output sent to ``/dev/null``; for
further details see the `source
further details see the `source
<https://github.com/cppformat/format-benchmark/blob/master/tinyformat_test.cpp>`_
_
.
<https://github.com/cppformat/format-benchmark/blob/master/tinyformat_test.cpp>`_.
============== ========
============== ========
test name run time
test name run time
...
@@ -260,7 +260,7 @@ boost::format 10.42s
...
@@ -260,7 +260,7 @@ boost::format 10.42s
============== ========
============== ========
As you can see boost::format is much slower than the alternative methods; this
As you can see boost::format is much slower than the alternative methods; this
is confirmed by `other tests <http://accu.org/index.php/journals/1539>`_
_
.
is confirmed by `other tests <http://accu.org/index.php/journals/1539>`_.
Tinyformat is quite good coming close to IOStreams. Unfortunately tinyformat
Tinyformat is quite good coming close to IOStreams. Unfortunately tinyformat
cannot be faster than the IOStreams because it uses them internally.
cannot be faster than the IOStreams because it uses them internally.
Performance of format is close to that of printf.
Performance of format is close to that of printf.
...
@@ -269,8 +269,8 @@ Compile time and code bloat
...
@@ -269,8 +269,8 @@ Compile time and code bloat
~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~
The script `bloat-test.py
The script `bloat-test.py
<https://github.com/cppformat/format-benchmark/blob/master/bloat-test.py>`_
_
<https://github.com/cppformat/format-benchmark/blob/master/bloat-test.py>`_
from `format-benchmark <https://github.com/cppformat/format-benchmark>`_
_
from `format-benchmark <https://github.com/cppformat/format-benchmark>`_
tests compile time and code bloat for nontrivial projects.
tests compile time and code bloat for nontrivial projects.
It generates 100 translation units and uses ``printf()`` or its alternative
It generates 100 translation units and uses ``printf()`` or its alternative
five times in each to simulate a medium sized project. The resulting
five times in each to simulate a medium sized project. The resulting
...
@@ -318,10 +318,10 @@ To run the unit tests first get the source code by cloning the repository::
...
@@ -318,10 +318,10 @@ To run the unit tests first get the source code by cloning the repository::
$ git clone https://github.com/cppformat/cppformat.git
$ git clone https://github.com/cppformat/cppformat.git
or downloading a package from
or downloading a package from
`Releases <https://github.com/cppformat/cppformat/releases>`_
_
.
`Releases <https://github.com/cppformat/cppformat/releases>`_.
Then go to the cppformat directory, generate Makefiles with
Then go to the cppformat directory, generate Makefiles with
`CMake <http://www.cmake.org/>`_
_
and build the project::
`CMake <http://www.cmake.org/>`_ and build the project::
$ cd cppformat
$ cd cppformat
$ cmake .
$ cmake .
...
@@ -332,7 +332,7 @@ Now you can run the unit tests::
...
@@ -332,7 +332,7 @@ Now you can run the unit tests::
$ make test
$ make test
Benchmarks reside in a separate repository,
Benchmarks reside in a separate repository,
`format-benchmarks <https://github.com/cppformat/format-benchmark>`_
_
,
`format-benchmarks <https://github.com/cppformat/format-benchmark>`_,
so to run the benchmarks you first need to clone this repository and
so to run the benchmarks you first need to clone this repository and
generate Makefiles with CMake::
generate Makefiles with CMake::
...
@@ -379,31 +379,31 @@ Documentation License
...
@@ -379,31 +379,31 @@ Documentation License
---------------------
---------------------
The `Format String Syntax
The `Format String Syntax
<http://cppformat.readthedocs.org/en/latest/#format-string-syntax>`_
_
<http://cppformat.readthedocs.org/en/latest/#format-string-syntax>`_
section in the documentation is based on the one from Python `string module
section in the documentation is based on the one from Python `string module
documentation <http://docs.python.org/3/library/string.html#module-string>`_
_
documentation <http://docs.python.org/3/library/string.html#module-string>`_
adapted for the current library. For this reason the documentation is
adapted for the current library. For this reason the documentation is
distributed under the Python Software Foundation license available in
distributed under the Python Software Foundation license available in
`doc/LICENSE.python
`doc/LICENSE.python
<https://raw.github.com/cppformat/cppformat/master/doc/LICENSE.python>`_
_
.
<https://raw.github.com/cppformat/cppformat/master/doc/LICENSE.python>`_.
Acknowledgments
Acknowledgments
---------------
---------------
The benchmark section of this readme file and the performance tests are taken
The benchmark section of this readme file and the performance tests are taken
from the excellent `tinyformat <https://github.com/c42f/tinyformat>`_
_
library
from the excellent `tinyformat <https://github.com/c42f/tinyformat>`_ library
written by Chris Foster. Boost Format library is acknowledged transitively
written by Chris Foster. Boost Format library is acknowledged transitively
since it had some influence on tinyformat.
since it had some influence on tinyformat.
Some ideas used in the implementation are borrowed from `Loki
Some ideas used in the implementation are borrowed from `Loki
<http://loki-lib.sourceforge.net/>`_
_
SafeFormat and `Diagnostic API
<http://loki-lib.sourceforge.net/>`_ SafeFormat and `Diagnostic API
<http://clang.llvm.org/doxygen/classclang_1_1Diagnostic.html>`_
_
in
<http://clang.llvm.org/doxygen/classclang_1_1Diagnostic.html>`_ in
`Clang <http://clang.llvm.org/>`_
_
.
`Clang <http://clang.llvm.org/>`_.
Format string syntax and the documentation are based on Python's `str.format
Format string syntax and the documentation are based on Python's `str.format
<http://docs.python.org/2/library/stdtypes.html#str.format>`_
_
.
<http://docs.python.org/2/library/stdtypes.html#str.format>`_.
Thanks `Doug Turnbull <https://github.com/softwaredoug>`_
_
for his valuable
Thanks `Doug Turnbull <https://github.com/softwaredoug>`_ for his valuable
comments and contribution to the design of the type-safe API and
comments and contribution to the design of the type-safe API and
`Gregory Czajkowski <https://github.com/gcflymoto>`_
_
for implementing binary
`Gregory Czajkowski <https://github.com/gcflymoto>`_ for implementing binary
formatting. Thanks `Ruslan Baratov <https://github.com/ruslo>`_
_
for comprehensive
formatting. Thanks `Ruslan Baratov <https://github.com/ruslo>`_ for comprehensive
`comparison of integer formatting algorithms <https://github.com/ruslo/int-dec-format-tests>`_
_
`comparison of integer formatting algorithms <https://github.com/ruslo/int-dec-format-tests>`_
and useful comments regarding performance, `Boris Kaul <https://github.com/localvoid>`_
_
for
and useful comments regarding performance, `Boris Kaul <https://github.com/localvoid>`_ for
`C++ counting digits benchmark <https://github.com/localvoid/cxx-benchmark-count-digits>`_
_
.
`C++ counting digits benchmark <https://github.com/localvoid/cxx-benchmark-count-digits>`_.
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