1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

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

This commit is contained in:
Lucas CHOLLET 2023-12-02 20:19:53 -05:00 committed by Andreas Kling
parent 6e282538cc
commit b82f5d7f3e

View file

@ -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