libcamera: utils: Add hex stream output helper

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 <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Laurent Pinchart
2019-10-13 22:22:04 +03:00
parent ce739e616c
commit f391048a7b
11 changed files with 147 additions and 22 deletions
+2 -5
View File
@@ -16,6 +16,7 @@
#include <libcamera/request.h>
#include "log.h"
#include "utils.h"
/**
* \file stream.h
@@ -367,11 +368,7 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats)
std::string StreamConfiguration::toString() const
{
std::stringstream ss;
ss.fill(0);
ss << size.toString() << "-0x" << std::hex << std::setw(8)
<< pixelFormat;
ss << size.toString() << "-" << utils::hex(pixelFormat);
return ss.str();
}