Ver Fonte

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.
sin-ack há 3 anos atrás
pai
commit
7da00bfa8d
1 ficheiros alterados com 24 adições e 0 exclusões
  1. 24 0
      AK/SourceGenerator.h

+ 24 - 0
AK/SourceGenerator.h

@@ -83,6 +83,30 @@ public:
         m_builder.append('\n');
         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:
 private:
     StringBuilder& m_builder;
     StringBuilder& m_builder;
     MappingType m_mapping;
     MappingType m_mapping;