summaryrefslogtreecommitdiff
path: root/src/string_utils.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2021-07-31 09:45:05 +1000
committerMaxime Coste <mawww@kakoune.org>2021-07-31 09:45:05 +1000
commit1728274803431581c123bdd3eb0275d1447f7966 (patch)
tree3703317a6daa3bdd6e2f801a6c82f5f21ffb16e8 /src/string_utils.hh
parenta566a22cbc4dd5c1f26256ae7bf380af93a62b14 (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.hh9
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)