소스 검색

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 3 년 전
부모
커밋
7da00bfa8d
1개의 변경된 파일24개의 추가작업 그리고 0개의 파일을 삭제
  1. 24 0
      AK/SourceGenerator.h

+ 24 - 0
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;