ソースを参照

LibGfx/TIFF: Add a C++ formatter for `TIFF::Value`

Lucas CHOLLET 1 年間 前
コミット
b82f5d7f3e
1 ファイル変更18 行追加0 行削除
  1. 18 0
      Userland/Libraries/LibGfx/TIFFGenerator.py

+ 18 - 0
Userland/Libraries/LibGfx/TIFFGenerator.py

@@ -309,6 +309,24 @@ struct AK::Formatter<Gfx::TIFF::Rational<T>> : Formatter<FormatString> {{
             static_cast<double>(value.numerator) / value.denominator, value.numerator, value.denominator);
     }}
 }};
+
+template<>
+struct AK::Formatter<Gfx::TIFF::Value> : Formatter<FormatString> {{
+    ErrorOr<void> format(FormatBuilder& builder, Gfx::TIFF::Value const& value)
+    {{
+        String content;
+        value.visit(
+            [&](ByteBuffer const& buffer) {{
+                content = MUST(String::formatted("Buffer of size: {{}}"sv, buffer.size()));
+            }},
+            [&](auto const& other) {{
+                content = MUST(String::formatted("{{}}", other));
+            }}
+        );
+
+        return Formatter<FormatString>::format(builder, "{{}}"sv, content);
+    }}
+}};
 """
     return output