3#ifndef TETL_FORMAT_FORMAT_TO_HPP
4#define TETL_FORMAT_FORMAT_TO_HPP
12template <
typename Iter>
19template <
typename OutputIt,
typename... Args>
25 auto const slices = detail::split_at_next_argument(fmt);
26 detail::format_escaped_sequences(slices.first, ctx);
30 auto rest = slices.second;
35 detail::format_argument(args, ctx);
38 auto const restSlices = detail::split_at_next_argument(rest);
39 detail::format_escaped_sequences(restSlices.first, ctx);
42 rest = restSlices.second;
46 if (
auto const trailing = detail::split_at_next_argument(rest); !trailing.first.empty()) {
47 detail::format_escaped_sequences(trailing.first, ctx);
58template <
typename Out>
68template <
typename OutputIter,
typename... Args>
77 auto writeChar = [&result](
auto ch) {
83 for (
decltype(fmt)::size_type i{}; i < fmt.size(); ++i) {
86 if ((fmt.size() > i + 1) && (fmt[i + 1] ==
'{')) {
97 if ((fmt.size() > i + 1) && (fmt[i + 1] ==
'}')) {
103 indices.push_back(varStart);
111 if (indices.size() > 0) {
112 [[maybe_unused]]
auto replaceCharAt = [n](
auto output,
auto pos,
char val) {
118 [[maybe_unused]]
typename decltype(indices)::size_type i{};
119 (replaceCharAt(out, indices[i++], args), ...);
#define TETL_ASSERT(...)
Definition assert.hpp:63
basic_string_view< char, etl::char_traits< char > > string_view
Typedef for common character type char
Definition basic_string_view.hpp:704
Definition adjacent_find.hpp:8
typename etl::iterator_traits< etl::remove_cvref_t< Iter > >::difference_type diff_t
Definition format_to.hpp:13
auto format_to(OutputIt out, etl::string_view fmt, Args const &... args) -> OutputIt
Format args according to the format string fmt, and write the result to the output iterator out.
Definition format_to.hpp:20
constexpr auto ignore_unused(Types &&...) -> void
Explicitly ignore arguments or variables.
Definition ignore_unused.hpp:17
TETL_BUILTIN_SIZET size_t
etl::size_t is the unsigned integer type of the result of the sizeof operator.
Definition size_t.hpp:14
auto format_to_n(OutputIter out, diff_t< OutputIter > n, etl::string_view fmt, Args const &... args) -> format_to_n_result< OutputIter >
Format args according to the format string fmt, and write the result to the output iterator out....
Definition format_to.hpp:69
basic_format_context< back_insert_iterator< detail::fmt_buffer< char > >, char > format_context
Provides access to formatting state consisting of the formatting arguments and the output iterator.
Definition basic_format_context.hpp:55
iterator_traits is the type trait class that provides uniform interface to the properties of LegacyIt...
Definition iterator_traits.hpp:47
Dynamically-resizable fixed-capacity vector.
Definition static_vector.hpp:329