LibGfx/TIFF: Move Formatter<Rational>'s definition to TIFFMetadata.h

This will soon be used in TIFFTagHandler.cpp, so the definition needs to
be shared.
This commit is contained in:
Lucas CHOLLET 2023-12-02 19:51:29 -05:00 committed by Andreas Kling
parent 71fdf0860e
commit 1d345109c4
Notes: sideshowbarker 2024-07-16 22:54:10 +09:00
2 changed files with 12 additions and 13 deletions

View file

@ -511,11 +511,3 @@ ErrorOr<Optional<ReadonlyBytes>> TIFFImageDecoderPlugin::icc_data()
}
}
template<typename T>
struct AK::Formatter<Gfx::TIFF::Rational<T>> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, Gfx::TIFF::Rational<T> value)
{
return Formatter<FormatString>::format(builder, "{} ({}/{})"sv, static_cast<double>(value.numerator) / value.denominator, value.numerator, value.denominator);
}
};

View file

@ -258,12 +258,19 @@ using Value = Variant<ByteBuffer, String, u32, Rational<u32>, i32, Rational<i32>
}}
{generate_metadata_class(tags)}
}}
template<typename T>
struct AK::Formatter<Gfx::TIFF::Rational<T>> : Formatter<FormatString> {{
ErrorOr<void> format(FormatBuilder& builder, Gfx::TIFF::Rational<T> value)
{{
return Formatter<FormatString>::format(builder, "{{}} ({{}}/{{}})"sv,
static_cast<double>(value.numerator) / value.denominator, value.numerator, value.denominator);
}}
}};
"""
output += generate_metadata_class(tags)
output += '\n}\n'
return output