mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 19:24:48 +02:00
ArgFormatter -> arg_formatter
This commit is contained in:
16
fmt/format.h
16
fmt/format.h
@@ -381,10 +381,10 @@ template <typename Context>
|
||||
class basic_arg;
|
||||
|
||||
template <typename Char>
|
||||
class ArgFormatter;
|
||||
class arg_formatter;
|
||||
|
||||
template <typename Char>
|
||||
class PrintfArgFormatter;
|
||||
class printf_arg_formatter;
|
||||
|
||||
template <typename Char>
|
||||
class basic_context;
|
||||
@@ -2016,7 +2016,7 @@ class context_base {
|
||||
|
||||
/** The default argument formatter. */
|
||||
template <typename Char>
|
||||
class ArgFormatter : public internal::ArgFormatterBase<Char> {
|
||||
class arg_formatter : public internal::ArgFormatterBase<Char> {
|
||||
private:
|
||||
basic_context<Char> &ctx_;
|
||||
|
||||
@@ -2033,8 +2033,8 @@ class ArgFormatter : public internal::ArgFormatterBase<Char> {
|
||||
format specifier information for standard argument types.
|
||||
\endrst
|
||||
*/
|
||||
ArgFormatter(basic_buffer<Char> &buffer, basic_context<Char> &ctx,
|
||||
format_specs &spec)
|
||||
arg_formatter(basic_buffer<Char> &buffer, basic_context<Char> &ctx,
|
||||
format_specs &spec)
|
||||
: internal::ArgFormatterBase<Char>(buffer, spec), ctx_(ctx) {}
|
||||
|
||||
using internal::ArgFormatterBase<Char>::operator();
|
||||
@@ -2277,7 +2277,7 @@ class basic_writer {
|
||||
friend class internal::ArgFormatterBase;
|
||||
|
||||
template <typename Char_>
|
||||
friend class PrintfArgFormatter;
|
||||
friend class printf_arg_formatter;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -2939,11 +2939,11 @@ void vformat_to(basic_buffer<Char> &buffer, BasicCStringRef<Char> format_str,
|
||||
basic_args<Context> args);
|
||||
|
||||
inline void vformat_to(buffer &buf, CStringRef format_str, args args) {
|
||||
vformat_to<ArgFormatter<char>>(buf, format_str, args);
|
||||
vformat_to<arg_formatter<char>>(buf, format_str, args);
|
||||
}
|
||||
|
||||
inline void vformat_to(wbuffer &buf, WCStringRef format_str, wargs args) {
|
||||
vformat_to<ArgFormatter<wchar_t>>(buf, format_str, args);
|
||||
vformat_to<arg_formatter<wchar_t>>(buf, format_str, args);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
|
@@ -86,7 +86,7 @@ void format_value(basic_buffer<Char> &buf, const T &value,
|
||||
internal::MemoryBuffer<Char, internal::INLINE_BUFFER_SIZE> buffer;
|
||||
internal::format_value(buffer, value);
|
||||
basic_string_view<Char> str(buffer.data(), buffer.size());
|
||||
do_format_arg< ArgFormatter<Char> >(
|
||||
do_format_arg< arg_formatter<Char> >(
|
||||
buf, internal::make_arg< basic_context<Char> >(str), ctx);
|
||||
}
|
||||
|
||||
|
@@ -210,7 +210,7 @@ class PrintfWidthHandler {
|
||||
\endrst
|
||||
*/
|
||||
template <typename Char>
|
||||
class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
|
||||
class printf_arg_formatter : public internal::ArgFormatterBase<Char> {
|
||||
private:
|
||||
void write_null_pointer() {
|
||||
this->spec().type_ = 0;
|
||||
@@ -229,7 +229,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
|
||||
specifier information for standard argument types.
|
||||
\endrst
|
||||
*/
|
||||
PrintfArgFormatter(basic_buffer<Char> &buffer, format_specs &spec)
|
||||
printf_arg_formatter(basic_buffer<Char> &buffer, format_specs &spec)
|
||||
: internal::ArgFormatterBase<Char>(buffer, spec) {}
|
||||
|
||||
using Base::operator();
|
||||
@@ -295,7 +295,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
|
||||
|
||||
/** This template formats data and writes the output to a writer. */
|
||||
template <typename Char,
|
||||
typename ArgFormatter = PrintfArgFormatter<Char> >
|
||||
typename ArgFormatter = printf_arg_formatter<Char> >
|
||||
class printf_context :
|
||||
private internal::context_base<
|
||||
Char, printf_context<Char, ArgFormatter>> {
|
||||
|
@@ -10,38 +10,38 @@
|
||||
#include "fmt/printf.h"
|
||||
#include "gtest-extra.h"
|
||||
|
||||
using fmt::PrintfArgFormatter;
|
||||
using fmt::printf_arg_formatter;
|
||||
|
||||
// A custom argument formatter that doesn't print `-` for floating-point values
|
||||
// rounded to 0.
|
||||
class CustomArgFormatter : public fmt::ArgFormatter<char> {
|
||||
class CustomArgFormatter : public fmt::arg_formatter<char> {
|
||||
public:
|
||||
CustomArgFormatter(fmt::buffer &buf, fmt::basic_context<char> &ctx,
|
||||
fmt::format_specs &s)
|
||||
: fmt::ArgFormatter<char>(buf, ctx, s) {}
|
||||
: fmt::arg_formatter<char>(buf, ctx, s) {}
|
||||
|
||||
using fmt::ArgFormatter<char>::operator();
|
||||
using fmt::arg_formatter<char>::operator();
|
||||
|
||||
void operator()(double value) {
|
||||
if (round(value * pow(10, spec().precision())) == 0)
|
||||
value = 0;
|
||||
fmt::ArgFormatter<char>::operator()(value);
|
||||
fmt::arg_formatter<char>::operator()(value);
|
||||
}
|
||||
};
|
||||
|
||||
// A custom argument formatter that doesn't print `-` for floating-point values
|
||||
// rounded to 0.
|
||||
class CustomPrintfArgFormatter : public PrintfArgFormatter<char> {
|
||||
class CustomPrintfArgFormatter : public printf_arg_formatter<char> {
|
||||
public:
|
||||
CustomPrintfArgFormatter(fmt::buffer &buf, fmt::format_specs &spec)
|
||||
: PrintfArgFormatter<char>(buf, spec) {}
|
||||
: printf_arg_formatter<char>(buf, spec) {}
|
||||
|
||||
using PrintfArgFormatter<char>::operator();
|
||||
using printf_arg_formatter<char>::operator();
|
||||
|
||||
void operator()(double value) {
|
||||
if (round(value * pow(10, spec().precision())) == 0)
|
||||
value = 0;
|
||||
PrintfArgFormatter<char>::operator()(value);
|
||||
printf_arg_formatter<char>::operator()(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -58,9 +58,9 @@ TEST(OStreamTest, Enum) {
|
||||
EXPECT_EQ("0", fmt::format("{}", A));
|
||||
}
|
||||
|
||||
struct TestArgFormatter : fmt::ArgFormatter<char> {
|
||||
struct TestArgFormatter : fmt::arg_formatter<char> {
|
||||
TestArgFormatter(fmt::buffer &buf, fmt::context &ctx, fmt::format_specs &s)
|
||||
: fmt::ArgFormatter<char>(buf, ctx, s) {}
|
||||
: fmt::arg_formatter<char>(buf, ctx, s) {}
|
||||
};
|
||||
|
||||
TEST(OStreamTest, CustomArg) {
|
||||
|
Reference in New Issue
Block a user