24 using size_type = std::string::size_type;
29 : m_Data{std::move(s)}
33 operator std::string_view()
const noexcept
40 m_Data.append(count, c);
52 const auto pos{m_Data.size() - std::ranges::min(count, m_Data.size())};
70 const indentation no_indent{
""};
74 std::string
indent(std::string_view sv, indentation ind);
87 std::string&
append_indented(std::string& s1, std::string_view s2, indentation ind);
90 std::string
append_indented(std::string_view sv1, std::string_view sv2, indentation ind);
94 template<
class... Ts, std::size_t... I>
95 std::string&
append_indented(std::string& s, std::tuple<Ts...> strs, std::index_sequence<I...>)
97 (
append_indented(s, std::get<I>(strs), std::get<
sizeof...(Ts) - 1>(strs)), ...);
101 template<
class... Ts>
102 std::string&
append_indented(std::string& s,
const std::tuple<Ts...>& strs)
104 return append_indented(s, strs, std::make_index_sequence<
sizeof...(Ts) - 1>{});
107 template<
class... Ts>
109 std::string
indent(std::string_view sv,
const std::tuple<Ts...>& strs)
111 auto s{
indent(sv, std::get<
sizeof...(Ts) - 1>(strs))};
116 template<
class... Ts>
117 requires (
sizeof...(Ts) > 2)
120 return sequoia::impl::append_indented(s, std::tuple<Ts...>{strs...});
123 template<
class... Ts>
124 requires (
sizeof...(Ts) > 2)
132 template<
class... Ts>
133 requires (
sizeof...(Ts) > 1)
135 std::string
indent(std::string_view sv, Ts&&... strs)
137 return sequoia::impl::indent(sv, std::tuple<Ts...>{std::forward<Ts>(strs)...});
140 template<
class... Ts>
141 requires (
sizeof...(Ts) > 0)
142 std::string& append_lines(std::string& s, Ts&&... strs)
147 template<
class... Ts>
148 requires (
sizeof...(Ts) > 0)
150 std::string append_lines(std::string_view sv, Ts&&... strs)
153 return append_lines(str, std::forward<Ts>(strs)...);
156 std::string& tabs_to_spacing(std::string& text, std::string_view spacing);
std::string indent(std::string_view sv, indentation ind)
For a non-empty string_view prepends with an indentation; otherwise returns an empty string.
Definition: Indent.cpp:16
std::string & append_indented(std::string &s1, std::string_view s2, indentation ind)
Definition: Indent.cpp:44
Type-safe mechanism for indentations.
Definition: Indent.hpp:22