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