From 296e9cada282fef262e230f29406304297b74ef7 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 28 Jan 2017 12:51:35 +0000 Subject: [PATCH] FrmatSpec -> format_spec --- fmt/format.h | 34 +++++++++++++++++----------------- fmt/printf.h | 20 ++++++++++---------- test/custom-formatter-test.cc | 4 ++-- test/format-test.cc | 2 +- test/ostream-test.cc | 4 ++-- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/fmt/format.h b/fmt/format.h index 265c14b2..d4009910 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -1738,8 +1738,8 @@ struct AlignTypeSpec : AlignSpec { char type() const { return TYPE; } }; -// A full format specifier. -class FormatSpec : public AlignSpec { +// Format specifiers. +class format_specs : public AlignSpec { private: template void set(fill_spec fill) { @@ -1765,11 +1765,11 @@ class FormatSpec : public AlignSpec { int precision_; char type_; - FormatSpec(unsigned width = 0, char type = 0, wchar_t fill = ' ') + format_specs(unsigned width = 0, char type = 0, wchar_t fill = ' ') : AlignSpec(width, fill), flags_(0), precision_(-1), type_(type) {} template - explicit FormatSpec(FormatSpecs... specs) + explicit format_specs(FormatSpecs... specs) : AlignSpec(0, ' '), flags_(0), precision_(-1), type_(0){ set(specs...); } @@ -1855,7 +1855,7 @@ template class ArgFormatterBase { private: basic_writer &writer_; - FormatSpec &spec_; + format_specs &spec_; FMT_DISALLOW_COPY_AND_ASSIGN(ArgFormatterBase); @@ -1883,7 +1883,7 @@ class ArgFormatterBase { protected: basic_writer &writer() { return writer_; } - FormatSpec &spec() { return spec_; } + format_specs &spec() { return spec_; } void write(bool value) { writer_.write_str(StringRef(value ? "true" : "false"), spec_); @@ -1897,7 +1897,7 @@ class ArgFormatterBase { public: typedef Char char_type; - ArgFormatterBase(basic_writer &w, FormatSpec &s) + ArgFormatterBase(basic_writer &w, format_specs &s) : writer_(w), spec_(s) {} void operator()(monostate) { @@ -2045,7 +2045,7 @@ class ArgFormatter : public internal::ArgFormatterBase { \endrst */ ArgFormatter(basic_writer &writer, basic_format_context &ctx, - FormatSpec &spec) + format_specs &spec) : internal::ArgFormatterBase(writer, spec), ctx_(ctx) {} using internal::ArgFormatterBase::operator(); @@ -2255,14 +2255,14 @@ class basic_writer { // Formats a floating-point number (double or long double). template - void write_double(T value, const FormatSpec &spec); + void write_double(T value, const format_specs &spec); // Writes a formatted string. template CharPtr write_str(const StrChar *s, std::size_t size, const AlignSpec &spec); template - void write_str(BasicStringRef str, const FormatSpec &spec); + void write_str(BasicStringRef str, const format_specs &spec); // This following methods are private to disallow writing wide characters // and strings to a char buffer. If you want to print a wide string as a @@ -2382,11 +2382,11 @@ class basic_writer { template typename std::enable_if::value, void>::type write(T value, FormatSpecs... specs) { - write_int(value, FormatSpec(specs...)); + write_int(value, format_specs(specs...)); } void write(double value) { - write_double(value, FormatSpec()); + write_double(value, format_specs()); } /** @@ -2396,7 +2396,7 @@ class basic_writer { \endrst */ void write(long double value) { - write_double(value, FormatSpec()); + write_double(value, format_specs()); } /** @@ -2427,7 +2427,7 @@ class basic_writer { template void write(BasicStringRef str, FormatSpecs... specs) { - write_str(str, FormatSpec(specs...)); + write_str(str, format_specs(specs...)); } void clear() FMT_NOEXCEPT { buffer_.clear(); } @@ -2461,7 +2461,7 @@ typename basic_writer::CharPtr basic_writer::write_str( template template void basic_writer::write_str( - BasicStringRef s, const FormatSpec &spec) { + BasicStringRef s, const format_specs &spec) { // Check if StrChar is convertible to Char. internal::CharTraits::convert(StrChar()); if (spec.type_ && spec.type_ != 's') @@ -2649,7 +2649,7 @@ void basic_writer::write_int(T value, Spec spec) { template template -void basic_writer::write_double(T value, const FormatSpec &spec) { +void basic_writer::write_double(T value, const format_specs &spec) { // Check type. char type = spec.type(); bool upper = false; @@ -3366,7 +3366,7 @@ template void do_format_arg(basic_writer &writer, basic_format_arg arg, Context &ctx) { const Char *&s = ctx.ptr(); - FormatSpec spec; + format_specs spec; if (*s == ':') { if (visit(internal::CustomFormatter(writer, ctx), arg)) return; diff --git a/fmt/printf.h b/fmt/printf.h index 0219ef8e..c2694e43 100644 --- a/fmt/printf.h +++ b/fmt/printf.h @@ -170,12 +170,12 @@ class CharConverter { // left alignment if it is negative. class PrintfWidthHandler { private: - FormatSpec &spec_; + format_specs &spec_; FMT_DISALLOW_COPY_AND_ASSIGN(PrintfWidthHandler); public: - explicit PrintfWidthHandler(FormatSpec &spec) : spec_(spec) {} + explicit PrintfWidthHandler(format_specs &spec) : spec_(spec) {} template typename std::enable_if::value, unsigned>::type @@ -224,14 +224,14 @@ class PrintfArgFormatter : public internal::ArgFormatterBase { specifier information for standard argument types. \endrst */ - PrintfArgFormatter(basic_writer &writer, FormatSpec &spec) + PrintfArgFormatter(basic_writer &writer, format_specs &spec) : internal::ArgFormatterBase(writer, spec) {} using Base::operator(); /** Formats an argument of type ``bool``. */ void operator()(bool value) { - FormatSpec &fmt_spec = this->spec(); + format_specs &fmt_spec = this->spec(); if (fmt_spec.type_ != 's') return (*this)(value ? 1 : 0); fmt_spec.type_ = 0; @@ -240,7 +240,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase { /** Formats a character. */ void operator()(Char value) { - const FormatSpec &fmt_spec = this->spec(); + const format_specs &fmt_spec = this->spec(); basic_writer &w = this->writer(); if (fmt_spec.type_ && fmt_spec.type_ != 'c') w.write_int(value, fmt_spec); @@ -302,7 +302,7 @@ class printf_context : typedef internal::format_context_base Base; typedef typename Base::format_arg format_arg; - void parse_flags(FormatSpec &spec, const Char *&s); + void parse_flags(format_specs &spec, const Char *&s); // Returns the argument with specified index or, if arg_index is equal // to the maximum unsigned value, the next argument. @@ -311,7 +311,7 @@ class printf_context : unsigned arg_index = (std::numeric_limits::max)()); // Parses argument index, flags and width and returns the argument index. - unsigned parse_header(const Char *&s, FormatSpec &spec); + unsigned parse_header(const Char *&s, format_specs &spec); public: /** @@ -330,7 +330,7 @@ class printf_context : }; template -void printf_context::parse_flags(FormatSpec &spec, const Char *&s) { +void printf_context::parse_flags(format_specs &spec, const Char *&s) { for (;;) { switch (*s++) { case '-': @@ -369,7 +369,7 @@ typename printf_context::format_arg printf_context::get_arg( template unsigned printf_context::parse_header( - const Char *&s, FormatSpec &spec) { + const Char *&s, format_specs &spec) { unsigned arg_index = std::numeric_limits::max(); Char c = *s; if (c >= '0' && c <= '9') { @@ -415,7 +415,7 @@ void printf_context::format(basic_writer &writer) { } internal::write(writer, start, s - 1); - FormatSpec spec; + format_specs spec; spec.align_ = ALIGN_RIGHT; // Parse argument index, flags and width. diff --git a/test/custom-formatter-test.cc b/test/custom-formatter-test.cc index e1ece844..8c646211 100644 --- a/test/custom-formatter-test.cc +++ b/test/custom-formatter-test.cc @@ -17,7 +17,7 @@ using fmt::PrintfArgFormatter; class CustomArgFormatter : public fmt::ArgFormatter { public: CustomArgFormatter(fmt::writer &w, fmt::basic_format_context &ctx, - fmt::FormatSpec &s) + fmt::format_specs &s) : fmt::ArgFormatter(w, ctx, s) {} using fmt::ArgFormatter::operator(); @@ -33,7 +33,7 @@ class CustomArgFormatter : public fmt::ArgFormatter { // rounded to 0. class CustomPrintfArgFormatter : public PrintfArgFormatter { public: - CustomPrintfArgFormatter(fmt::basic_writer &w, fmt::FormatSpec &spec) + CustomPrintfArgFormatter(fmt::basic_writer &w, fmt::format_specs &spec) : PrintfArgFormatter(w, spec) {} using PrintfArgFormatter::operator(); diff --git a/test/format-test.cc b/test/format-test.cc index 656551cb..db9faef0 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1644,7 +1644,7 @@ class MockArgFormatter : public fmt::internal::ArgFormatterBase { typedef fmt::internal::ArgFormatterBase Base; MockArgFormatter(fmt::writer &w, fmt::format_context &ctx, - fmt::FormatSpec &s) + fmt::format_specs &s) : fmt::internal::ArgFormatterBase(w, s) { EXPECT_CALL(*this, call(42)); } diff --git a/test/ostream-test.cc b/test/ostream-test.cc index b5c46a61..c2498e90 100644 --- a/test/ostream-test.cc +++ b/test/ostream-test.cc @@ -60,14 +60,14 @@ TEST(OStreamTest, Enum) { struct TestArgFormatter : fmt::ArgFormatter { TestArgFormatter(fmt::writer &w, fmt::format_context &ctx, - fmt::FormatSpec &s) + fmt::format_specs &s) : fmt::ArgFormatter(w, ctx, s) {} }; TEST(OStreamTest, CustomArg) { fmt::MemoryWriter writer; fmt::format_context ctx("}", fmt::format_args()); - fmt::FormatSpec spec; + fmt::format_specs spec; TestArgFormatter af(writer, ctx, spec); visit(af, fmt::internal::make_arg(TestEnum())); EXPECT_EQ("TestEnum", writer.str());