summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-04-29 04:31:48 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-05-04 14:11:30 +0300
commit2efd8ab36ae3cde16d772a7f6285b592662e8630 (patch)
treec7979cb2698355273b7d426b8ee4c620299486e3 /src
parente8f35e5f33597bb40a994df3eb836955e95d5095 (diff)
libcamera: Add operator<<() for pixel format classes
Implement the stream output operator<<() for the PixelFormat and V4L2PixelFormat classes to simplify printing them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/pixel_format.cpp12
-rw-r--r--src/libcamera/v4l2_pixelformat.cpp13
2 files changed, 25 insertions, 0 deletions
diff --git a/src/libcamera/pixel_format.cpp b/src/libcamera/pixel_format.cpp
index 997aeb8a..80c22072 100644
--- a/src/libcamera/pixel_format.cpp
+++ b/src/libcamera/pixel_format.cpp
@@ -140,4 +140,16 @@ PixelFormat PixelFormat::fromString(const std::string &name)
return PixelFormatInfo::info(name).format;
}
+/**
+ * \brief Insert a text representation of a PixelFormat into an output stream
+ * \param[in] out The output stream
+ * \param[in] f The PixelFormat
+ * \return The output stream \a out
+ */
+std::ostream &operator<<(std::ostream &out, const PixelFormat &f)
+{
+ out << f.toString();
+ return out;
+}
+
} /* namespace libcamera */
diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
index 0e0da3f0..1dd93baa 100644
--- a/src/libcamera/v4l2_pixelformat.cpp
+++ b/src/libcamera/v4l2_pixelformat.cpp
@@ -316,4 +316,17 @@ V4L2PixelFormat V4L2PixelFormat::fromPixelFormat(const PixelFormat &pixelFormat,
return multiplanar ? info.v4l2Formats.multi : info.v4l2Formats.single;
}
+/**
+ * \brief Insert a text representation of a V4L2PixelFormat into an output
+ * stream
+ * \param[in] out The output stream
+ * \param[in] f The V4L2PixelFormat
+ * \return The output stream \a out
+ */
+std::ostream &operator<<(std::ostream &out, const V4L2PixelFormat &f)
+{
+ out << f.toString();
+ return out;
+}
+
} /* namespace libcamera */