mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-11 21:38:05 +00:00
Remove printf_arg_formatter from format.h and cleanup
This commit is contained in:
parent
44a26e5e21
commit
af00e4f9c9
26
fmt/format.h
26
fmt/format.h
@ -356,30 +356,22 @@ namespace fmt {
|
||||
using std::move;
|
||||
#endif
|
||||
|
||||
template <typename Char>
|
||||
class basic_buffer;
|
||||
|
||||
typedef basic_buffer<char> buffer;
|
||||
typedef basic_buffer<wchar_t> wbuffer;
|
||||
|
||||
template <typename Char>
|
||||
class basic_writer;
|
||||
|
||||
template <typename Context>
|
||||
class basic_arg;
|
||||
|
||||
template <typename Char>
|
||||
class arg_formatter;
|
||||
|
||||
template <typename Char>
|
||||
class printf_arg_formatter;
|
||||
|
||||
template <typename Char>
|
||||
class basic_context;
|
||||
|
||||
typedef basic_context<char> context;
|
||||
typedef basic_context<wchar_t> wcontext;
|
||||
|
||||
// A formatter for objects of type T.
|
||||
template <typename T, typename Char = char, typename Enable = void>
|
||||
struct formatter;
|
||||
|
||||
/**
|
||||
\rst
|
||||
An implementation of ``std::basic_string_view`` for pre-C++17. It provides a
|
||||
@ -482,10 +474,6 @@ class format_error : public std::runtime_error {
|
||||
~format_error() throw();
|
||||
};
|
||||
|
||||
// A formatter for objects of type T.
|
||||
template <typename T, typename Char = char, typename Enable = void>
|
||||
struct formatter;
|
||||
|
||||
namespace internal {
|
||||
|
||||
// Casts nonnegative integer to unsigned.
|
||||
@ -589,6 +577,9 @@ class basic_buffer {
|
||||
virtual std::locale locale() const { return std::locale(); }
|
||||
};
|
||||
|
||||
typedef basic_buffer<char> buffer;
|
||||
typedef basic_buffer<wchar_t> wbuffer;
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
void basic_buffer<T>::append(const U *begin, const U *end) {
|
||||
@ -2304,9 +2295,6 @@ class basic_writer {
|
||||
template <typename Char_>
|
||||
friend class internal::arg_formatter_base;
|
||||
|
||||
template <typename Char_>
|
||||
friend class printf_arg_formatter;
|
||||
|
||||
public:
|
||||
/**
|
||||
Constructs a ``basic_writer`` object.
|
||||
|
22
fmt/printf.h
22
fmt/printf.h
@ -241,25 +241,13 @@ class printf_arg_formatter : public internal::arg_formatter_base<Char> {
|
||||
|
||||
/** Formats a character. */
|
||||
void operator()(Char value) {
|
||||
const format_specs &fmt_spec = this->spec();
|
||||
format_specs &fmt_spec = this->spec();
|
||||
basic_writer<Char> &w = this->writer();
|
||||
if (fmt_spec.type_ && fmt_spec.type_ != 'c')
|
||||
w.write_int(value, fmt_spec);
|
||||
typedef typename basic_writer<Char>::pointer_type pointer_type;
|
||||
pointer_type out = pointer_type();
|
||||
if (fmt_spec.width_ > 1) {
|
||||
Char fill = ' ';
|
||||
out = w.grow_buffer(fmt_spec.width_);
|
||||
if (fmt_spec.align_ != ALIGN_LEFT) {
|
||||
std::fill_n(out, fmt_spec.width_ - 1, fill);
|
||||
out += fmt_spec.width_ - 1;
|
||||
} else {
|
||||
std::fill_n(out + 1, fmt_spec.width_ - 1, fill);
|
||||
}
|
||||
} else {
|
||||
out = w.grow_buffer(1);
|
||||
}
|
||||
*out = static_cast<Char>(value);
|
||||
return (*this)(static_cast<int>(value));
|
||||
fmt_spec.flags_ = 0;
|
||||
fmt_spec.align_ = ALIGN_RIGHT;
|
||||
Base::operator()(value);
|
||||
}
|
||||
|
||||
/** Formats a null-terminated C string. */
|
||||
|
@ -137,7 +137,7 @@ TEST(PrintfTest, ZeroFlag) {
|
||||
EXPECT_PRINTF("+00042", "%00+6d", 42);
|
||||
|
||||
// '0' flag is ignored for non-numeric types.
|
||||
EXPECT_PRINTF(" x", "%05c", 'x');
|
||||
EXPECT_PRINTF("0000x", "%05c", 'x');
|
||||
}
|
||||
|
||||
TEST(PrintfTest, PlusFlag) {
|
||||
|
Loading…
Reference in New Issue
Block a user