From 88456ab55adb5593826afc073448aab50665631c Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Thu, 5 Dec 2024 11:00:29 +0100 Subject: libcamera: stream: Add operator<<(StreamConfiguration) The StreamConfiguration class only implements toString() but doesn't offer an overload of operator<<() which is more convenient to use. Add an overload for operator<<(StreamConfiguration) and re-implement StreamConfiguration::toString() on top of it. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Stefan Klug Reviewed-by: Laurent Pinchart --- src/libcamera/stream.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 1f75dbbc..978d7275 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -392,7 +392,23 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats) */ std::string StreamConfiguration::toString() const { - return size.toString() + "-" + pixelFormat.toString(); + std::stringstream ss; + ss << *this; + + return ss.str(); +} + +/** + * \brief Insert a text representation of a StreamConfiguration into an output + * stream + * \param[in] out The output stream + * \param[in] cfg The StreamConfiguration + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, const StreamConfiguration &cfg) +{ + out << cfg.size << "-" << cfg.pixelFormat; + return out; } /** -- cgit v1.2.1