From 7da00bfa8d03741e74a0a50f0c17a15b92ca94e2 Mon Sep 17 00:00:00 2001 From: sin-ack Date: Tue, 12 Jul 2022 00:58:29 +0000 Subject: [PATCH] AK: Add string literal helpers to AK::SourceGenerator Since all uses of SourceGenerator are with literal strings, there is no need to burden generators with the sv suffix. --- AK/SourceGenerator.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/AK/SourceGenerator.h b/AK/SourceGenerator.h index 3e875a2973..23adb74499 100644 --- a/AK/SourceGenerator.h +++ b/AK/SourceGenerator.h @@ -83,6 +83,30 @@ public: m_builder.append('\n'); } + template + String get(char const (&key)[N]) + { + return get(StringView { key, N - 1 }); + } + + template + void set(char const (&key)[N], String value) + { + set(StringView { key, N - 1 }, value); + } + + template + void append(char const (&pattern)[N]) + { + append(StringView { pattern, N - 1 }); + } + + template + void appendln(char const (&pattern)[N]) + { + appendln(StringView { pattern, N - 1 }); + } + private: StringBuilder& m_builder; MappingType m_mapping;