From f391048a7b987a149d0ba5421846b9b5ab916338 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 13 Oct 2019 22:22:04 +0300 Subject: libcamera: utils: Add hex stream output helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a utils::hex() function that simplifies writing hexadecimal values to an ostream. The function handles the '0x' prefix, the field width and the fill character automatically. Use it through the libcamera code base, and add a test. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/v4l2_subdevice.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/libcamera/v4l2_subdevice.cpp') diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index a188298d..f2bcd7f7 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -21,6 +21,7 @@ #include "log.h" #include "media_device.h" #include "media_object.h" +#include "utils.h" /** * \file v4l2_subdevice.h @@ -76,10 +77,7 @@ LOG_DECLARE_CATEGORY(V4L2) const std::string V4L2SubdeviceFormat::toString() const { std::stringstream ss; - - ss.fill(0); - ss << size.toString() << "-0x" << std::hex << std::setw(4) << mbus_code; - + ss << size.toString() << "-" << utils::hex(mbus_code, 4); return ss.str(); } -- cgit v1.2.1