mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-22 18:40:05 +00:00
context_base::begin -> out
This commit is contained in:
parent
b1f68c43b5
commit
fa9066fe3e
@ -840,7 +840,8 @@ class context_base {
|
||||
void on_error(const char *message) { parse_context_.on_error(message); }
|
||||
|
||||
// Returns an iterator to the beginning of the output range.
|
||||
iterator begin() { return out_; }
|
||||
iterator out() { return out_; }
|
||||
iterator begin() { return out_; } // deprecated
|
||||
|
||||
// Advances the begin iterator to ``it``.
|
||||
void advance_to(iterator it) { out_ = it; }
|
||||
|
@ -2216,7 +2216,7 @@ class arg_formatter:
|
||||
\endrst
|
||||
*/
|
||||
arg_formatter(context_type &ctx, format_specs &spec)
|
||||
: base(Range(ctx.begin()), spec), ctx_(ctx) {}
|
||||
: base(Range(ctx.out()), spec), ctx_(ctx) {}
|
||||
|
||||
using base::operator();
|
||||
|
||||
@ -3096,7 +3096,7 @@ struct formatter<
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const T &val, FormatContext &ctx) -> decltype(ctx.begin()) {
|
||||
auto format(const T &val, FormatContext &ctx) -> decltype(ctx.out()) {
|
||||
internal::handle_dynamic_spec<internal::width_checker>(
|
||||
specs_.width_, specs_.width_ref, ctx);
|
||||
internal::handle_dynamic_spec<internal::precision_checker>(
|
||||
@ -3105,7 +3105,7 @@ struct formatter<
|
||||
typename FormatContext::char_type> range;
|
||||
visit(arg_formatter<range>(ctx, specs_),
|
||||
internal::make_arg<FormatContext>(val));
|
||||
return ctx.begin();
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -3154,7 +3154,7 @@ class dynamic_formatter {
|
||||
}
|
||||
|
||||
template <typename T, typename FormatContext>
|
||||
auto format(const T &val, FormatContext &ctx) -> decltype(ctx.begin()) {
|
||||
auto format(const T &val, FormatContext &ctx) -> decltype(ctx.out()) {
|
||||
handle_specs(ctx);
|
||||
internal::specs_checker<null_handler>
|
||||
checker(null_handler(), internal::get_type<FormatContext, T>::value);
|
||||
@ -3177,7 +3177,7 @@ class dynamic_formatter {
|
||||
typename FormatContext::char_type> range;
|
||||
visit(arg_formatter<range>(ctx, specs_),
|
||||
internal::make_arg<FormatContext>(val));
|
||||
return ctx.begin();
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -3213,7 +3213,7 @@ struct format_handler : internal::error_handler {
|
||||
|
||||
void on_text(iterator begin, iterator end) {
|
||||
size_t size = end - begin;
|
||||
auto out = context.begin();
|
||||
auto out = context.out();
|
||||
auto &&it = internal::reserve(out, size);
|
||||
it = std::copy_n(begin, size, it);
|
||||
context.advance_to(out);
|
||||
@ -3265,7 +3265,7 @@ typename Context::iterator vformat_to(typename ArgFormatter::range out,
|
||||
typedef internal::null_terminating_iterator<Char> iterator;
|
||||
format_handler<ArgFormatter, Char, Context> h(out, format_str, args);
|
||||
parse_format_string(iterator(format_str.begin(), format_str.end()), h);
|
||||
return h.context.begin();
|
||||
return h.context.out();
|
||||
}
|
||||
|
||||
// Casts ``p`` to ``const void*`` for pointer formatting.
|
||||
@ -3289,10 +3289,10 @@ struct formatter<arg_join<It, Char>, Char>:
|
||||
formatter<typename std::iterator_traits<It>::value_type, Char> {
|
||||
template <typename FormatContext>
|
||||
auto format(const arg_join<It, Char> &value, FormatContext &ctx)
|
||||
-> decltype(ctx.begin()) {
|
||||
-> decltype(ctx.out()) {
|
||||
typedef formatter<typename std::iterator_traits<It>::value_type, Char> base;
|
||||
auto it = value.begin;
|
||||
auto out = ctx.begin();
|
||||
auto out = ctx.out();
|
||||
if (it != value.end) {
|
||||
out = base::format(*it++, ctx);
|
||||
while (it != value.end) {
|
||||
|
@ -112,12 +112,12 @@ struct formatter<T, Char,
|
||||
: formatter<basic_string_view<Char>, Char> {
|
||||
|
||||
template <typename Context>
|
||||
auto format(const T &value, Context &ctx) -> decltype(ctx.begin()) {
|
||||
auto format(const T &value, Context &ctx) -> decltype(ctx.out()) {
|
||||
basic_memory_buffer<Char> buffer;
|
||||
internal::format_value(buffer, value);
|
||||
basic_string_view<Char> str(buffer.data(), buffer.size());
|
||||
formatter<basic_string_view<Char>, Char>::format(str, ctx);
|
||||
return ctx.begin();
|
||||
return ctx.out();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -298,9 +298,9 @@ struct printf_formatter {
|
||||
auto parse(ParseContext &ctx) -> decltype(ctx.begin()) { return ctx.begin(); }
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const T &value, FormatContext &ctx) -> decltype(ctx.begin()) {
|
||||
internal::format_value(internal::get_container(ctx.begin()), value);
|
||||
return ctx.begin();
|
||||
auto format(const T &value, FormatContext &ctx) -> decltype(ctx.out()) {
|
||||
internal::format_value(internal::get_container(ctx.out()), value);
|
||||
return ctx.out();
|
||||
}
|
||||
};
|
||||
|
||||
@ -346,7 +346,7 @@ class basic_printf_context :
|
||||
: base(out, format_str, args) {}
|
||||
|
||||
using base::parse_context;
|
||||
using base::begin;
|
||||
using base::out;
|
||||
using base::advance_to;
|
||||
|
||||
/** Formats stored arguments and writes the output to the range. */
|
||||
@ -429,7 +429,7 @@ unsigned basic_printf_context<OutputIt, Char, AF>::parse_header(
|
||||
|
||||
template <typename OutputIt, typename Char, typename AF>
|
||||
void basic_printf_context<OutputIt, Char, AF>::format() {
|
||||
auto &buffer = internal::get_container(this->begin());
|
||||
auto &buffer = internal::get_container(this->out());
|
||||
auto start = iterator(this->parse_context());
|
||||
auto it = start;
|
||||
using internal::pointer_from;
|
||||
|
@ -121,8 +121,8 @@ struct formatter<std::tm, Char> {
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const std::tm &tm, FormatContext &ctx) -> decltype(ctx.begin()) {
|
||||
internal::basic_buffer<Char> &buf = internal::get_container(ctx.begin());
|
||||
auto format(const std::tm &tm, FormatContext &ctx) -> decltype(ctx.out()) {
|
||||
internal::basic_buffer<Char> &buf = internal::get_container(ctx.out());
|
||||
std::size_t start = buf.size();
|
||||
for (;;) {
|
||||
std::size_t size = buf.capacity() - start;
|
||||
@ -141,7 +141,7 @@ struct formatter<std::tm, Char> {
|
||||
const std::size_t MIN_GROWTH = 10;
|
||||
buf.reserve(buf.capacity() + (size > MIN_GROWTH ? size : MIN_GROWTH));
|
||||
}
|
||||
return ctx.begin();
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
basic_memory_buffer<Char> tm_format;
|
||||
|
@ -1101,9 +1101,9 @@ struct formatter<Date> {
|
||||
return it;
|
||||
}
|
||||
|
||||
auto format(const Date &d, format_context &ctx) -> decltype(ctx.begin()) {
|
||||
format_to(ctx.begin(), "{}-{}-{}", d.year(), d.month(), d.day());
|
||||
return ctx.begin();
|
||||
auto format(const Date &d, format_context &ctx) -> decltype(ctx.out()) {
|
||||
format_to(ctx.out(), "{}-{}-{}", d.year(), d.month(), d.day());
|
||||
return ctx.out();
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -1119,7 +1119,7 @@ class Answer {};
|
||||
namespace fmt {
|
||||
template <>
|
||||
struct formatter<Answer> : formatter<int> {
|
||||
auto format(Answer, fmt::format_context &ctx) -> decltype(ctx.begin()) {
|
||||
auto format(Answer, fmt::format_context &ctx) -> decltype(ctx.out()) {
|
||||
return formatter<int>::format(42, ctx);
|
||||
}
|
||||
};
|
||||
@ -1410,7 +1410,7 @@ class mock_arg_formatter:
|
||||
typedef buffer_range range;
|
||||
|
||||
mock_arg_formatter(fmt::format_context &ctx, fmt::format_specs &s)
|
||||
: base(fmt::internal::get_container(ctx.begin()), s) {
|
||||
: base(fmt::internal::get_container(ctx.out()), s) {
|
||||
EXPECT_CALL(*this, call(42));
|
||||
}
|
||||
|
||||
@ -1454,7 +1454,7 @@ struct variant {
|
||||
namespace fmt {
|
||||
template <>
|
||||
struct formatter<variant> : dynamic_formatter<> {
|
||||
auto format(variant value, format_context& ctx) -> decltype(ctx.begin()) {
|
||||
auto format(variant value, format_context& ctx) -> decltype(ctx.out()) {
|
||||
if (value.type == variant::INT)
|
||||
return dynamic_formatter<>::format(42, ctx);
|
||||
return dynamic_formatter<>::format("foo", ctx);
|
||||
|
@ -65,9 +65,9 @@ struct formatter<Test, Char> {
|
||||
typedef std::back_insert_iterator<basic_buffer<Char>> iterator;
|
||||
|
||||
auto format(Test, basic_format_context<iterator, char> &ctx)
|
||||
-> decltype(ctx.begin()) {
|
||||
-> decltype(ctx.out()) {
|
||||
const Char *test = "test";
|
||||
return std::copy_n(test, std::strlen(test), ctx.begin());
|
||||
return std::copy_n(test, std::strlen(test), ctx.out());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user