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/controls.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/libcamera/controls.cpp') diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index e46aa438..6a0301f3 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -549,8 +549,7 @@ const ControlValue &ControlList::get(unsigned int id) const const auto ctrl = idmap_->find(id); if (ctrl == idmap_->end()) { LOG(Controls, Error) - << std::hex << std::setfill('0') - << "Control 0x" << std::setw(8) << id + << "Control " << utils::hex(id) << " is not supported"; return zero; } @@ -579,8 +578,7 @@ void ControlList::set(unsigned int id, const ControlValue &value) const auto ctrl = idmap_->find(id); if (ctrl == idmap_->end()) { LOG(Controls, Error) - << std::hex << std::setfill('0') - << "Control 0x" << std::setw(8) << id + << "Control 0x" << utils::hex(id) << " is not supported"; return; } -- cgit v1.2.1