mirror of
https://github.com/fmtlib/fmt.git
synced 2025-02-05 00:40:12 +00:00
Document output_file
This commit is contained in:
parent
018688da2a
commit
061e364b25
11
doc/api.rst
11
doc/api.rst
@ -16,6 +16,7 @@ The {fmt} library API consists of the following parts:
|
|||||||
* :ref:`fmt/chrono.h <chrono-api>`: date and time formatting
|
* :ref:`fmt/chrono.h <chrono-api>`: date and time formatting
|
||||||
* :ref:`fmt/compile.h <compile-api>`: format string compilation
|
* :ref:`fmt/compile.h <compile-api>`: format string compilation
|
||||||
* :ref:`fmt/color.h <color-api>`: terminal color and text style
|
* :ref:`fmt/color.h <color-api>`: terminal color and text style
|
||||||
|
* :ref:`fmt/os.h <os-api>`: system APIs
|
||||||
* :ref:`fmt/ostream.h <ostream-api>`: ``std::ostream`` support
|
* :ref:`fmt/ostream.h <ostream-api>`: ``std::ostream`` support
|
||||||
* :ref:`fmt/printf.h <printf-api>`: ``printf`` formatting
|
* :ref:`fmt/printf.h <printf-api>`: ``printf`` formatting
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ participate in an overload resolution if the latter is not a string.
|
|||||||
|
|
||||||
.. _print:
|
.. _print:
|
||||||
|
|
||||||
.. doxygenfunction:: print(const S &format_str, Args&&... args)
|
.. doxygenfunction:: fmt::print(const S &format_str, Args&&... args)
|
||||||
.. doxygenfunction:: vprint(string_view, format_args)
|
.. doxygenfunction:: vprint(string_view, format_args)
|
||||||
|
|
||||||
.. doxygenfunction:: print(std::FILE *f, const S &format_str, Args&&... args)
|
.. doxygenfunction:: print(std::FILE *f, const S &format_str, Args&&... args)
|
||||||
@ -471,6 +472,14 @@ Terminal color and text style
|
|||||||
|
|
||||||
.. doxygenfunction:: bg(detail::color_type)
|
.. doxygenfunction:: bg(detail::color_type)
|
||||||
|
|
||||||
|
.. _os-api:
|
||||||
|
|
||||||
|
System APIs
|
||||||
|
===========
|
||||||
|
|
||||||
|
.. doxygenclass:: fmt::ostream
|
||||||
|
:members:
|
||||||
|
|
||||||
.. _ostream-api:
|
.. _ostream-api:
|
||||||
|
|
||||||
``std::ostream`` Support
|
``std::ostream`` Support
|
||||||
|
@ -55,6 +55,7 @@ def build_docs(version='dev', **kwargs):
|
|||||||
ALIASES += "endrst=\endverbatim"
|
ALIASES += "endrst=\endverbatim"
|
||||||
MACRO_EXPANSION = YES
|
MACRO_EXPANSION = YES
|
||||||
PREDEFINED = _WIN32=1 \
|
PREDEFINED = _WIN32=1 \
|
||||||
|
__linux__=1 \
|
||||||
FMT_USE_VARIADIC_TEMPLATES=1 \
|
FMT_USE_VARIADIC_TEMPLATES=1 \
|
||||||
FMT_USE_RVALUE_REFERENCES=1 \
|
FMT_USE_RVALUE_REFERENCES=1 \
|
||||||
FMT_USE_USER_DEFINED_LITERALS=1 \
|
FMT_USE_USER_DEFINED_LITERALS=1 \
|
||||||
|
@ -373,7 +373,7 @@ struct ostream_params {
|
|||||||
|
|
||||||
static constexpr detail::buffer_size buffer_size;
|
static constexpr detail::buffer_size buffer_size;
|
||||||
|
|
||||||
// A fast output stream which is not thread-safe.
|
/** A fast output stream which is not thread-safe. */
|
||||||
class ostream final : private detail::buffer<char> {
|
class ostream final : private detail::buffer<char> {
|
||||||
private:
|
private:
|
||||||
file file_;
|
file file_;
|
||||||
@ -410,6 +410,10 @@ class ostream final : private detail::buffer<char> {
|
|||||||
file_.close();
|
file_.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Formats ``args`` according to specifications in ``format_str`` and writes
|
||||||
|
the output to the file.
|
||||||
|
*/
|
||||||
template <typename S, typename... Args>
|
template <typename S, typename... Args>
|
||||||
void print(const S& format_str, Args&&... args) {
|
void print(const S& format_str, Args&&... args) {
|
||||||
format_to(detail::buffer_appender<char>(*this), format_str,
|
format_to(detail::buffer_appender<char>(*this), format_str,
|
||||||
@ -418,9 +422,19 @@ class ostream final : private detail::buffer<char> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Opens a file for writing. Supported parameters passed in `params`:
|
\rst
|
||||||
* ``<integer>``: Output flags (``file::WRONLY | file::CREATE`` by default)
|
Opens a file for writing. Supported parameters passed in *params*:
|
||||||
|
|
||||||
|
* ``<integer>``: Flags passed to `open
|
||||||
|
<https://pubs.opengroup.org/onlinepubs/007904875/functions/open.html>`_
|
||||||
|
(``file::WRONLY | file::CREATE`` by default)
|
||||||
* ``buffer_size=<integer>``: Output buffer size
|
* ``buffer_size=<integer>``: Output buffer size
|
||||||
|
|
||||||
|
**Example**::
|
||||||
|
|
||||||
|
auto out = fmt::output_file("guide.txt");
|
||||||
|
out.print("Don't {}", "Panic");
|
||||||
|
\endrst
|
||||||
*/
|
*/
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
inline ostream output_file(cstring_view path, T... params) {
|
inline ostream output_file(cstring_view path, T... params) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user