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
83920084
Commit
83920084
authored
May 13, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update docs.
parent
891da2f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
20 deletions
+67
-20
doc/Doxyfile
doc/Doxyfile
+4
-1
doc/index.rst
doc/index.rst
+6
-1
format.h
format.h
+57
-18
No files found.
doc/Doxyfile
View file @
83920084
...
@@ -12,4 +12,7 @@ GENERATE_XML = YES
...
@@ -12,4 +12,7 @@ GENERATE_XML = YES
XML_OUTPUT = doxyxml
XML_OUTPUT = doxyxml
ALIASES = "rst=\verbatim embed:rst"
ALIASES = "rst=\verbatim embed:rst"
ALIASES += "endrst=\endverbatim"
ALIASES += "endrst=\endverbatim"
PREDEFINED = FMT_USE_VARIADIC_TEMPLATES
PREDEFINED = FMT_USE_VARIADIC_TEMPLATES=1 \
FMT_USE_RVALUE_REFERENCES=1
EXCLUDE_SYMBOLS = fmt::internal::* VFormat ArgInfo BasicArg CustomValue FormatParser \
NullArgAction StringValue ArgAction
\ No newline at end of file
doc/index.rst
View file @
83920084
...
@@ -7,13 +7,18 @@ C++ Format Library API
...
@@ -7,13 +7,18 @@ C++ Format Library API
All functions and classes provided by the C++ Format library reside
All functions and classes provided by the C++ Format library reside
in namespace ``fmt`` and macros have prefix ``FMT_``. For brevity the
in namespace ``fmt`` and macros have prefix ``FMT_``. For brevity the
namespace is
often
omitted in examples.
namespace is
usually
omitted in examples.
.. doxygenfunction:: fmt::Format(StringRef)
.. doxygenfunction:: fmt::Format(StringRef)
.. doxygenfunction:: fmt::Format(StringRef, const Args &...)
.. doxygenclass:: fmt::BasicWriter
.. doxygenclass:: fmt::BasicWriter
:members:
:members:
.. doxygenclass:: fmt::BasicFormatter
:members:
.. doxygenclass:: fmt::Formatter
.. doxygenclass:: fmt::Formatter
:members:
:members:
...
...
format.h
View file @
83920084
...
@@ -996,11 +996,21 @@ class BasicWriter {
...
@@ -996,11 +996,21 @@ class BasicWriter {
};
};
public:
public:
/**
Constructs a ``BasicWriter`` object.
*/
BasicWriter
()
{}
BasicWriter
()
{}
#if FMT_USE_RVALUE_REFERENCES
#if FMT_USE_RVALUE_REFERENCES
/**
Constructs a ``BasicWriter`` object moving the content of the other
object to it.
*/
BasicWriter
(
BasicWriter
&&
other
)
:
buffer_
(
std
::
move
(
other
.
buffer_
))
{}
BasicWriter
(
BasicWriter
&&
other
)
:
buffer_
(
std
::
move
(
other
.
buffer_
))
{}
/**
Moves the content of the other ``BasicWriter`` object to this one.
*/
BasicWriter
&
operator
=
(
BasicWriter
&&
other
)
{
BasicWriter
&
operator
=
(
BasicWriter
&&
other
)
{
assert
(
this
!=
&
other
);
assert
(
this
!=
&
other
);
buffer_
=
std
::
move
(
other
.
buffer_
);
buffer_
=
std
::
move
(
other
.
buffer_
);
...
@@ -1009,7 +1019,7 @@ class BasicWriter {
...
@@ -1009,7 +1019,7 @@ class BasicWriter {
#endif
#endif
/**
/**
Returns the
number of characters written to the output buffer
.
Returns the
total number of characters written
.
*/
*/
std
::
size_t
size
()
const
{
return
buffer_
.
size
();
}
std
::
size_t
size
()
const
{
return
buffer_
.
size
();
}
...
@@ -1037,11 +1047,16 @@ class BasicWriter {
...
@@ -1037,11 +1047,16 @@ class BasicWriter {
return
std
::
basic_string
<
Char
>
(
&
buffer_
[
0
],
buffer_
.
size
());
return
std
::
basic_string
<
Char
>
(
&
buffer_
[
0
],
buffer_
.
size
());
}
}
inline
void
VFormat
(
BasicStringRef
<
Char
>
format
,
std
::
size_t
num_args
,
const
ArgInfo
*
args
)
{
FormatParser
().
Format
(
*
this
,
format
,
num_args
,
args
);
}
/**
/**
\rst
\rst
Formats a string sending the output to the writer. Arguments are
Formats a string sending the output to the writer. Arguments are
accepted through the returned
``BasicFormatter`` object using inserter
accepted through the returned
:cpp:class:`fmt::BasicFormatter` object
operator ``<<``.
using
operator ``<<``.
**Example**::
**Example**::
...
@@ -1056,23 +1071,23 @@ class BasicWriter {
...
@@ -1056,23 +1071,23 @@ class BasicWriter {
Current point:
Current point:
(-3.140000, +3.140000)
(-3.140000, +3.140000)
The output can be accessed using :meth:`data` or :meth:`c_str`.
The output can be accessed using :meth:`data`, :meth:`c_str` or :meth:`str`
methods.
See also `Format String Syntax`_.
See also `Format String Syntax`_.
\endrst
\endrst
*/
*/
BasicFormatter
<
Char
>
Format
(
StringRef
format
);
BasicFormatter
<
Char
>
Format
(
StringRef
format
);
inline
void
VFormat
(
BasicStringRef
<
Char
>
format
,
std
::
size_t
num_args
,
const
ArgInfo
*
args
)
{
FormatParser
().
Format
(
*
this
,
format
,
num_args
,
args
);
}
#if FMT_USE_VARIADIC_TEMPLATES
#if FMT_USE_VARIADIC_TEMPLATES
/**
/**
\rst
\rst
Formats a string sending the output to the writer.
Formats a string sending the output to the writer.
This version of the Format method uses C++11 features such as
variadic templates and rvalue references. For C++98 version, see
the overload taking a single ``StringRef`` argument above.
**Example**::
**Example**::
Writer out;
Writer out;
...
@@ -1086,7 +1101,8 @@ class BasicWriter {
...
@@ -1086,7 +1101,8 @@ class BasicWriter {
Current point:
Current point:
(-3.140000, +3.140000)
(-3.140000, +3.140000)
The output can be accessed using :meth:`data` or :meth:`c_str`.
The output can be accessed using :meth:`data`, :meth:`c_str` or :meth:`str`
methods.
See also `Format String Syntax`_.
See also `Format String Syntax`_.
\endrst
\endrst
...
@@ -1312,11 +1328,8 @@ void FormatCustomArg(
...
@@ -1312,11 +1328,8 @@ void FormatCustomArg(
/**
/**
\rst
\rst
The :cpp:class:`fmt::BasicFormatter` template provides string formatting
The :cpp:class:`fmt::BasicFormatter` template provides operator<< for
functionality similar to Python's `str.format
feeding arbitrary arguments to the :cpp:func:`fmt::Format()` function.
<http://docs.python.org/3/library/stdtypes.html#str.format>`__ function.
The class provides operator<< for feeding formatting arguments and all
the output is sent to a :cpp:class:`fmt::Writer` object.
\endrst
\endrst
*/
*/
template
<
typename
Char
>
template
<
typename
Char
>
...
@@ -1532,9 +1545,9 @@ class Formatter : private Sink, public BasicFormatter<Char> {
...
@@ -1532,9 +1545,9 @@ class Formatter : private Sink, public BasicFormatter<Char> {
/**
/**
\rst
\rst
Formats a string similarly to Python's `str.format
Formats a string similarly to Python's `str.format
<http://docs.python.org/3/library/stdtypes.html#str.format>`__.
<http://docs.python.org/3/library/stdtypes.html#str.format>`__
function
.
Returns a temporary
formatter object that accepts arguments via
Returns a temporary
:cpp:class:`fmt::Formatter` object that accepts arguments
operator ``<<``.
via
operator ``<<``.
*format* is a format string that contains literal text and replacement
*format* is a format string that contains literal text and replacement
fields surrounded by braces ``{}``. The formatter object replaces the
fields surrounded by braces ``{}``. The formatter object replaces the
...
@@ -1575,10 +1588,12 @@ class SystemErrorSink {
...
@@ -1575,10 +1588,12 @@ class SystemErrorSink {
};
};
/**
/**
\rst
Formats a message and throws SystemError with the description of the form
Formats a message and throws SystemError with the description of the form
"<message>: <system-message>", where <message> is the formatted message and
"<message>: <system-message>", where <message> is the formatted message and
<system-message> is the system message corresponding to the error code.
<system-message> is the system message corresponding to the error code.
error_code is a system error code as given by errno.
error_code is a system error code as given by errno.
\endrst
*/
*/
inline
Formatter
<
SystemErrorSink
>
ThrowSystemError
(
inline
Formatter
<
SystemErrorSink
>
ThrowSystemError
(
int
error_code
,
StringRef
format
)
{
int
error_code
,
StringRef
format
)
{
...
@@ -1688,6 +1703,30 @@ inline Formatter<ANSITerminalSink> PrintColored(Color c, StringRef format) {
...
@@ -1688,6 +1703,30 @@ inline Formatter<ANSITerminalSink> PrintColored(Color c, StringRef format) {
#if FMT_USE_VARIADIC_TEMPLATES && FMT_USE_RVALUE_REFERENCES
#if FMT_USE_VARIADIC_TEMPLATES && FMT_USE_RVALUE_REFERENCES
/**
\rst
Formats a string similarly to Python's `str.format
<http://docs.python.org/3/library/stdtypes.html#str.format>`__ function
and returns an :cpp:class:`fmt::BasicWriter` object containing the output.
This version of the Format function uses C++11 features such as
variadic templates and rvalue references. For C++98 version, see
the :cpp:func:`fmt::Format()` overload above.
*format* is a format string that contains literal text and replacement
fields surrounded by braces ``{}``. The formatter object replaces the
fields with formatted arguments and stores the output in a memory buffer.
The content of the buffer can be converted to ``std::string`` with
:cpp:func:`fmt::str()` or accessed as a C string with
:cpp:func:`fmt::c_str()`.
**Example**::
std::string message = str(Format("The answer is {}", 42);
See also `Format String Syntax`_.
\endrst
*/
template
<
typename
...
Args
>
template
<
typename
...
Args
>
inline
Writer
Format
(
StringRef
format
,
const
Args
&
...
args
)
{
inline
Writer
Format
(
StringRef
format
,
const
Args
&
...
args
)
{
Writer
w
;
Writer
w
;
...
...
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