Commit 4ec88607 authored by Victor Zverovich's avatar Victor Zverovich

ArgFormatter -> arg_formatter

parent 50e71673
...@@ -381,10 +381,10 @@ template <typename Context> ...@@ -381,10 +381,10 @@ template <typename Context>
class basic_arg; class basic_arg;
template <typename Char> template <typename Char>
class ArgFormatter; class arg_formatter;
template <typename Char> template <typename Char>
class PrintfArgFormatter; class printf_arg_formatter;
template <typename Char> template <typename Char>
class basic_context; class basic_context;
...@@ -2016,7 +2016,7 @@ class context_base { ...@@ -2016,7 +2016,7 @@ class context_base {
/** The default argument formatter. */ /** The default argument formatter. */
template <typename Char> template <typename Char>
class ArgFormatter : public internal::ArgFormatterBase<Char> { class arg_formatter : public internal::ArgFormatterBase<Char> {
private: private:
basic_context<Char> &ctx_; basic_context<Char> &ctx_;
...@@ -2033,8 +2033,8 @@ class ArgFormatter : public internal::ArgFormatterBase<Char> { ...@@ -2033,8 +2033,8 @@ class ArgFormatter : public internal::ArgFormatterBase<Char> {
format specifier information for standard argument types. format specifier information for standard argument types.
\endrst \endrst
*/ */
ArgFormatter(basic_buffer<Char> &buffer, basic_context<Char> &ctx, arg_formatter(basic_buffer<Char> &buffer, basic_context<Char> &ctx,
format_specs &spec) format_specs &spec)
: internal::ArgFormatterBase<Char>(buffer, spec), ctx_(ctx) {} : internal::ArgFormatterBase<Char>(buffer, spec), ctx_(ctx) {}
using internal::ArgFormatterBase<Char>::operator(); using internal::ArgFormatterBase<Char>::operator();
...@@ -2277,7 +2277,7 @@ class basic_writer { ...@@ -2277,7 +2277,7 @@ class basic_writer {
friend class internal::ArgFormatterBase; friend class internal::ArgFormatterBase;
template <typename Char_> template <typename Char_>
friend class PrintfArgFormatter; friend class printf_arg_formatter;
public: public:
/** /**
...@@ -2939,11 +2939,11 @@ void vformat_to(basic_buffer<Char> &buffer, BasicCStringRef<Char> format_str, ...@@ -2939,11 +2939,11 @@ void vformat_to(basic_buffer<Char> &buffer, BasicCStringRef<Char> format_str,
basic_args<Context> args); basic_args<Context> args);
inline void vformat_to(buffer &buf, CStringRef format_str, args 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) { 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> template <typename... Args>
......
...@@ -86,7 +86,7 @@ void format_value(basic_buffer<Char> &buf, const T &value, ...@@ -86,7 +86,7 @@ void format_value(basic_buffer<Char> &buf, const T &value,
internal::MemoryBuffer<Char, internal::INLINE_BUFFER_SIZE> buffer; internal::MemoryBuffer<Char, internal::INLINE_BUFFER_SIZE> buffer;
internal::format_value(buffer, value); internal::format_value(buffer, value);
basic_string_view<Char> str(buffer.data(), buffer.size()); 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); buf, internal::make_arg< basic_context<Char> >(str), ctx);
} }
......
...@@ -210,7 +210,7 @@ class PrintfWidthHandler { ...@@ -210,7 +210,7 @@ class PrintfWidthHandler {
\endrst \endrst
*/ */
template <typename Char> template <typename Char>
class PrintfArgFormatter : public internal::ArgFormatterBase<Char> { class printf_arg_formatter : public internal::ArgFormatterBase<Char> {
private: private:
void write_null_pointer() { void write_null_pointer() {
this->spec().type_ = 0; this->spec().type_ = 0;
...@@ -229,7 +229,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> { ...@@ -229,7 +229,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
specifier information for standard argument types. specifier information for standard argument types.
\endrst \endrst
*/ */
PrintfArgFormatter(basic_buffer<Char> &buffer, format_specs &spec) printf_arg_formatter(basic_buffer<Char> &buffer, format_specs &spec)
: internal::ArgFormatterBase<Char>(buffer, spec) {} : internal::ArgFormatterBase<Char>(buffer, spec) {}
using Base::operator(); using Base::operator();
...@@ -295,7 +295,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> { ...@@ -295,7 +295,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
/** This template formats data and writes the output to a writer. */ /** This template formats data and writes the output to a writer. */
template <typename Char, template <typename Char,
typename ArgFormatter = PrintfArgFormatter<Char> > typename ArgFormatter = printf_arg_formatter<Char> >
class printf_context : class printf_context :
private internal::context_base< private internal::context_base<
Char, printf_context<Char, ArgFormatter>> { Char, printf_context<Char, ArgFormatter>> {
......
...@@ -10,38 +10,38 @@ ...@@ -10,38 +10,38 @@
#include "fmt/printf.h" #include "fmt/printf.h"
#include "gtest-extra.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 // A custom argument formatter that doesn't print `-` for floating-point values
// rounded to 0. // rounded to 0.
class CustomArgFormatter : public fmt::ArgFormatter<char> { class CustomArgFormatter : public fmt::arg_formatter<char> {
public: public:
CustomArgFormatter(fmt::buffer &buf, fmt::basic_context<char> &ctx, CustomArgFormatter(fmt::buffer &buf, fmt::basic_context<char> &ctx,
fmt::format_specs &s) 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) { void operator()(double value) {
if (round(value * pow(10, spec().precision())) == 0) if (round(value * pow(10, spec().precision())) == 0)
value = 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 // A custom argument formatter that doesn't print `-` for floating-point values
// rounded to 0. // rounded to 0.
class CustomPrintfArgFormatter : public PrintfArgFormatter<char> { class CustomPrintfArgFormatter : public printf_arg_formatter<char> {
public: public:
CustomPrintfArgFormatter(fmt::buffer &buf, fmt::format_specs &spec) 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) { void operator()(double value) {
if (round(value * pow(10, spec().precision())) == 0) if (round(value * pow(10, spec().precision())) == 0)
value = 0; value = 0;
PrintfArgFormatter<char>::operator()(value); printf_arg_formatter<char>::operator()(value);
} }
}; };
......
...@@ -58,9 +58,9 @@ TEST(OStreamTest, Enum) { ...@@ -58,9 +58,9 @@ TEST(OStreamTest, Enum) {
EXPECT_EQ("0", fmt::format("{}", A)); 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) 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) { TEST(OStreamTest, CustomArg) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment