libcamera: base: utils: Simplify hex adaptor

The libcamera hex string adaptor specifies and casts each type
specifically to map the size of each type.

This needlessly repeats itself for each type and further more has a bug
with signed integer extension which causes values such as 0x80 to be
printed as 0xffffffffffffff80 instead.

Remove the template specialisations for each type, and unify with a
single templated constructor of the struct hex trait.

Suggested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Kieran Bingham
2025-10-31 20:38:54 +00:00
committed by Laurent Pinchart
parent 06044ca70d
commit 760456acfc
3 changed files with 17 additions and 56 deletions
+2 -1
View File
@@ -187,7 +187,8 @@ std::string time_point_to_string(const time_point &time)
}
std::basic_ostream<char, std::char_traits<char>> &
operator<<(std::basic_ostream<char, std::char_traits<char>> &stream, const _hex &h)
details::operator<<(std::basic_ostream<char, std::char_traits<char>> &stream,
const details::hex &h)
{
stream << "0x";