do_vformat_to -> vformat_to and update docs

This commit is contained in:
Victor Zverovich 2018-03-04 06:40:43 -08:00
parent d07ba49821
commit 5281ea6ad2
5 changed files with 18 additions and 17 deletions

View File

@ -22,7 +22,7 @@ arguments in the resulting string.
*args* is an argument list representing objects to be formatted. *args* is an argument list representing objects to be formatted.
The `performance of the format API The `performance of the formating functions
<https://github.com/fmtlib/fmt/blob/master/README.rst#speed-tests>`_ is close <https://github.com/fmtlib/fmt/blob/master/README.rst#speed-tests>`_ is close
to that of glibc's ``printf`` and better than the performance of IOStreams. to that of glibc's ``printf`` and better than the performance of IOStreams.
@ -127,7 +127,7 @@ custom argument formatter class::
// with the ``x`` format specifier. // with the ``x`` format specifier.
class custom_arg_formatter : public arg_formatter { class custom_arg_formatter : public arg_formatter {
public: public:
custom_arg_formatter(context_type &ctx, fmt::format_specs &spec) custom_arg_formatter(fmt::context &ctx, fmt::format_specs &spec)
: arg_formatter(ctx, spec) {} : arg_formatter(ctx, spec) {}
using arg_formatter::operator(); using arg_formatter::operator();
@ -142,8 +142,8 @@ custom argument formatter class::
std::string custom_vformat(fmt::string_view format_str, fmt::format_args args) { std::string custom_vformat(fmt::string_view format_str, fmt::format_args args) {
fmt::memory_buffer buffer; fmt::memory_buffer buffer;
// Pass custom argument formatter as a template arg to do_vformat. // Pass custom argument formatter as a template arg to vformat_to.
fmt::do_vformat_to<custom_arg_formatter>(buffer, format_str, args); fmt::vformat_to<custom_arg_formatter>(buffer, format_str, args);
return fmt::to_string(buffer); return fmt::to_string(buffer);
} }

View File

@ -183,9 +183,10 @@ typename std::add_rvalue_reference<T>::type declval() FMT_NOEXCEPT;
/** /**
\rst \rst
An implementation of ``std::basic_string_view`` for pre-C++17. It provides a An implementation of ``std::basic_string_view`` for pre-C++17. It provides a
subset of the API. fmt::basic_string_view is used for format strings even if subset of the API. ``fmt::basic_string_view`` is used for format strings even
std::string_view is available to prevent issues when a library is compiled if ``std::string_view`` is available to prevent issues when a library is
with different -std option than the client code (which is not recommended). compiled with a different ``-std`` option than the client code (which is not
recommended).
\endrst \endrst
*/ */
template <typename Char> template <typename Char>

View File

@ -3197,7 +3197,7 @@ struct format_handler : internal::error_handler {
/** Formats arguments and writes the output to the buffer. */ /** Formats arguments and writes the output to the buffer. */
template <typename ArgFormatter, typename Char, typename Context> template <typename ArgFormatter, typename Char, typename Context>
typename Context::iterator do_vformat_to(typename ArgFormatter::range out, typename Context::iterator vformat_to(typename ArgFormatter::range out,
basic_string_view<Char> format_str, basic_string_view<Char> format_str,
basic_format_args<Context> args) { basic_format_args<Context> args) {
typedef internal::null_terminating_iterator<Char> iterator; typedef internal::null_terminating_iterator<Char> iterator;
@ -3327,13 +3327,13 @@ std::basic_string<Char> to_string(const basic_memory_buffer<Char> &buffer) {
inline void vformat_to(internal::buffer &buf, string_view format_str, inline void vformat_to(internal::buffer &buf, string_view format_str,
format_args args) { format_args args) {
typedef back_insert_range<internal::buffer> range; typedef back_insert_range<internal::buffer> range;
do_vformat_to<arg_formatter<range>>(buf, format_str, args); vformat_to<arg_formatter<range>>(buf, format_str, args);
} }
inline void vformat_to(internal::wbuffer &buf, wstring_view format_str, inline void vformat_to(internal::wbuffer &buf, wstring_view format_str,
wformat_args args) { wformat_args args) {
typedef back_insert_range<internal::wbuffer> range; typedef back_insert_range<internal::wbuffer> range;
do_vformat_to<arg_formatter<range>>(buf, format_str, args); vformat_to<arg_formatter<range>>(buf, format_str, args);
} }
template <typename... Args> template <typename... Args>
@ -3362,7 +3362,7 @@ template <typename OutputIt, typename... Args>
inline OutputIt vformat_to(OutputIt out, string_view format_str, inline OutputIt vformat_to(OutputIt out, string_view format_str,
typename format_args_t<OutputIt>::type args) { typename format_args_t<OutputIt>::type args) {
typedef output_range<OutputIt, char> range; typedef output_range<OutputIt, char> range;
return do_vformat_to<arg_formatter<range>>(range(out), format_str, args); return vformat_to<arg_formatter<range>>(range(out), format_str, args);
} }
template <typename OutputIt, typename... Args> template <typename OutputIt, typename... Args>
@ -3465,7 +3465,7 @@ FMT_CONSTEXPR internal::udl_formatter<Char, CHARS...> operator""_format() {
# else # else
/** /**
\rst \rst
C++11 literal equivalent of :func:`fmt::format`. User-defined literal equivalent of :func:`fmt::format`.
**Example**:: **Example**::
@ -3481,7 +3481,7 @@ operator"" _format(const wchar_t *s, std::size_t) { return {s}; }
/** /**
\rst \rst
C++11 literal equivalent of :func:`fmt::arg`. User-defined literal equivalent of :func:`fmt::arg`.
**Example**:: **Example**::

View File

@ -37,7 +37,7 @@ class CustomArgFormatter :
std::string custom_vformat(fmt::string_view format_str, fmt::format_args args) { std::string custom_vformat(fmt::string_view format_str, fmt::format_args args) {
fmt::memory_buffer buffer; fmt::memory_buffer buffer;
// Pass custom argument formatter as a template arg to vwrite. // Pass custom argument formatter as a template arg to vwrite.
fmt::do_vformat_to<CustomArgFormatter>(buffer, format_str, args); fmt::vformat_to<CustomArgFormatter>(buffer, format_str, args);
return std::string(buffer.data(), buffer.size()); return std::string(buffer.data(), buffer.size());
} }

View File

@ -1577,7 +1577,7 @@ class mock_arg_formatter:
void custom_vformat(fmt::string_view format_str, fmt::format_args args) { void custom_vformat(fmt::string_view format_str, fmt::format_args args) {
fmt::memory_buffer buffer; fmt::memory_buffer buffer;
fmt::do_vformat_to<mock_arg_formatter>(buffer, format_str, args); fmt::vformat_to<mock_arg_formatter>(buffer, format_str, args);
} }
template <typename... Args> template <typename... Args>