diff options
author | sin-ack <sin-ack@users.noreply.github.com> | 2022-07-12 00:58:29 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-12 23:11:35 +0200 |
commit | 7da00bfa8d03741e74a0a50f0c17a15b92ca94e2 (patch) | |
tree | a2631d65ffadf1d9da86e65902e3cb6800a79cc4 /AK | |
parent | 6eecc65787abd1dcbbff157e0c3be73b03a4c225 (diff) | |
download | serenity-7da00bfa8d03741e74a0a50f0c17a15b92ca94e2.zip |
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.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/SourceGenerator.h | 24 |
1 files changed, 24 insertions, 0 deletions
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<size_t N> + String get(char const (&key)[N]) + { + return get(StringView { key, N - 1 }); + } + + template<size_t N> + void set(char const (&key)[N], String value) + { + set(StringView { key, N - 1 }, value); + } + + template<size_t N> + void append(char const (&pattern)[N]) + { + append(StringView { pattern, N - 1 }); + } + + template<size_t N> + void appendln(char const (&pattern)[N]) + { + appendln(StringView { pattern, N - 1 }); + } + private: StringBuilder& m_builder; MappingType m_mapping; |