diff options
| author | Maxime Coste <mawww@kakoune.org> | 2021-07-31 09:45:05 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2021-07-31 09:45:05 +1000 |
| commit | 1728274803431581c123bdd3eb0275d1447f7966 (patch) | |
| tree | 3703317a6daa3bdd6e2f801a6c82f5f21ffb16e8 /src/string_utils.hh | |
| parent | a566a22cbc4dd5c1f26256ae7bf380af93a62b14 (diff) | |
Add a format_with format function that takes a FunctionRef append
Diffstat (limited to 'src/string_utils.hh')
| -rw-r--r-- | src/string_utils.hh | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/string_utils.hh b/src/string_utils.hh index 4da7ddc3..e0adc181 100644 --- a/src/string_utils.hh +++ b/src/string_utils.hh @@ -6,6 +6,7 @@ #include "vector.hh" #include "ranges.hh" #include "optional.hh" +#include "utils.hh" namespace Kakoune { @@ -161,6 +162,14 @@ StringView format_to(ArrayView<char> buffer, StringView fmt, Types&&... params) return format_to(buffer, fmt, ArrayView<const StringView>{detail::format_param(std::forward<Types>(params))...}); } +void format_with(FunctionRef<void (StringView)> append, StringView fmt, ArrayView<const StringView> params); + +template<typename... Types> +void format_with(FunctionRef<void (StringView)> append, StringView fmt, Types&&... params) +{ + return format_with(append, fmt, ArrayView<const StringView>{detail::format_param(std::forward<Types>(params))...}); +} + String double_up(StringView s, StringView characters); inline String quote(StringView s) |
