mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 11:17:35 +02:00
Remove uses of buffer_range
This commit is contained in:
43
test/format
43
test/format
@@ -488,24 +488,21 @@ template<class... Args>
|
|||||||
namespace std {
|
namespace std {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template <typename Range>
|
template <typename OutputIt, typename Char>
|
||||||
class arg_formatter
|
class arg_formatter
|
||||||
: public fmt::internal::arg_formatter_base<
|
: public fmt::internal::arg_formatter_base<OutputIt, Char, error_handler> {
|
||||||
typename Range::iterator, typename Range::value_type, error_handler> {
|
|
||||||
private:
|
private:
|
||||||
using char_type = typename Range::value_type;
|
using char_type = Char;
|
||||||
using base = fmt::internal::arg_formatter_base<
|
using base = fmt::internal::arg_formatter_base<OutputIt, Char, error_handler>;
|
||||||
typename Range::iterator, char_type, error_handler>;
|
using format_context = std::basic_format_context<OutputIt, Char>;
|
||||||
using format_context = std::basic_format_context<typename base::iterator, char_type>;
|
using parse_context = basic_format_parse_context<Char>;
|
||||||
using parse_context = basic_format_parse_context<char_type>;
|
|
||||||
|
|
||||||
parse_context* parse_ctx_;
|
parse_context* parse_ctx_;
|
||||||
format_context& ctx_;
|
format_context& ctx_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef Range range;
|
using iterator = OutputIt;
|
||||||
typedef typename base::iterator iterator;
|
using format_specs = typename base::format_specs;
|
||||||
typedef typename base::format_specs format_specs;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\rst
|
\rst
|
||||||
@@ -584,12 +581,12 @@ class custom_formatter {
|
|||||||
|
|
||||||
template <typename ArgFormatter, typename Char, typename Context>
|
template <typename ArgFormatter, typename Char, typename Context>
|
||||||
struct format_handler : detail::error_handler {
|
struct format_handler : detail::error_handler {
|
||||||
typedef typename ArgFormatter::range range;
|
using iterator = typename ArgFormatter::iterator;
|
||||||
|
|
||||||
format_handler(range r, basic_string_view<Char> str,
|
format_handler(iterator out, basic_string_view<Char> str,
|
||||||
basic_format_args<Context> format_args,
|
basic_format_args<Context> format_args,
|
||||||
fmt::internal::locale_ref loc)
|
fmt::internal::locale_ref loc)
|
||||||
: parse_ctx(str), context(r.begin(), format_args, loc) {}
|
: parse_ctx(str), context(out, format_args, loc) {}
|
||||||
|
|
||||||
void on_text(const Char* begin, const Char* end) {
|
void on_text(const Char* begin, const Char* end) {
|
||||||
auto size = fmt::internal::to_unsigned(end - begin);
|
auto size = fmt::internal::to_unsigned(end - begin);
|
||||||
@@ -694,9 +691,9 @@ struct formatter {
|
|||||||
specs_.width, specs_.width_ref, ctx);
|
specs_.width, specs_.width_ref, ctx);
|
||||||
fmt::internal::handle_dynamic_spec<fmt::internal::precision_checker>(
|
fmt::internal::handle_dynamic_spec<fmt::internal::precision_checker>(
|
||||||
specs_.precision, specs_.precision_ref, ctx);
|
specs_.precision, specs_.precision_ref, ctx);
|
||||||
using range_type = fmt::internal::output_range<typename FormatContext::iterator,
|
using af = arg_formatter<typename FormatContext::iterator,
|
||||||
typename FormatContext::char_type>;
|
typename FormatContext::char_type>;
|
||||||
return visit_format_arg(arg_formatter<range_type>(ctx, nullptr, &specs_),
|
return visit_format_arg(af(ctx, nullptr, &specs_),
|
||||||
basic_format_arg<FormatContext>(val));
|
basic_format_arg<FormatContext>(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -719,9 +716,9 @@ template<class... Args>
|
|||||||
string vformat(string_view fmt, format_args args) {
|
string vformat(string_view fmt, format_args args) {
|
||||||
fmt::memory_buffer mbuf;
|
fmt::memory_buffer mbuf;
|
||||||
fmt::internal::buffer<char>& buf = mbuf;
|
fmt::internal::buffer<char>& buf = mbuf;
|
||||||
using range = fmt::buffer_range<char>;
|
using af = detail::arg_formatter<fmt::format_context::iterator, char>;
|
||||||
detail::format_handler<detail::arg_formatter<range>, char, format_context>
|
detail::format_handler<af, char, format_context>
|
||||||
h(range(std::back_inserter(buf)), fmt, args, {});
|
h(std::back_inserter(buf), fmt, args, {});
|
||||||
fmt::internal::parse_format_string<false>(fmt::to_string_view(fmt), h);
|
fmt::internal::parse_format_string<false>(fmt::to_string_view(fmt), h);
|
||||||
return to_string(mbuf);
|
return to_string(mbuf);
|
||||||
}
|
}
|
||||||
@@ -742,9 +739,9 @@ template<class Out, class... Args>
|
|||||||
|
|
||||||
template<class Out>
|
template<class Out>
|
||||||
Out vformat_to(Out out, string_view fmt, format_args_t<fmt::type_identity_t<Out>, char> args) {
|
Out vformat_to(Out out, string_view fmt, format_args_t<fmt::type_identity_t<Out>, char> args) {
|
||||||
using range = fmt::internal::output_range<Out, char>;
|
using af = detail::arg_formatter<Out, char>;
|
||||||
detail::format_handler<detail::arg_formatter<range>, char, basic_format_context<Out, char>>
|
detail::format_handler<af, char, basic_format_context<Out, char>>
|
||||||
h(range(out), fmt, args, {});
|
h(out, fmt, args, {});
|
||||||
fmt::internal::parse_format_string<false>(fmt::to_string_view(fmt), h);
|
fmt::internal::parse_format_string<false>(fmt::to_string_view(fmt), h);
|
||||||
return h.context.out();
|
return h.context.out();
|
||||||
}
|
}
|
||||||
|
@@ -1806,10 +1806,10 @@ TEST(FormatTest, StrongEnum) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using buffer_range = fmt::buffer_range<char>;
|
using buffer_iterator = fmt::format_context::iterator;
|
||||||
|
|
||||||
class mock_arg_formatter
|
class mock_arg_formatter
|
||||||
: public fmt::detail::arg_formatter_base<buffer_range::iterator, char> {
|
: public fmt::detail::arg_formatter_base<buffer_iterator, char> {
|
||||||
private:
|
private:
|
||||||
#if FMT_USE_INT128
|
#if FMT_USE_INT128
|
||||||
MOCK_METHOD1(call, void(__int128_t value));
|
MOCK_METHOD1(call, void(__int128_t value));
|
||||||
@@ -1818,8 +1818,7 @@ class mock_arg_formatter
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef fmt::detail::arg_formatter_base<buffer_range::iterator, char> base;
|
using base = fmt::detail::arg_formatter_base<buffer_iterator, char>;
|
||||||
typedef buffer_range range;
|
|
||||||
|
|
||||||
mock_arg_formatter(fmt::format_context& ctx, fmt::format_parse_context*,
|
mock_arg_formatter(fmt::format_context& ctx, fmt::format_parse_context*,
|
||||||
fmt::format_specs* s = nullptr)
|
fmt::format_specs* s = nullptr)
|
||||||
|
Reference in New Issue
Block a user