[libcamera-devel] [PATCH] libcamera: request: Add operator<<()

Jacopo Mondi jacopo at jmondi.org
Fri Jun 3 11:32:24 CEST 2022


With the recent addition of operator<<() to most libcamera core classes
to replace usage of the toString() function, the Request class was left
behind.

Add operator<<() for the Request class.

Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
 include/libcamera/request.h |  3 +++
 src/libcamera/request.cpp   | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/include/libcamera/request.h b/include/libcamera/request.h
index 1eb537e9b09b..dffde1536cad 100644
--- a/include/libcamera/request.h
+++ b/include/libcamera/request.h
@@ -9,6 +9,7 @@
 
 #include <map>
 #include <memory>
+#include <ostream>
 #include <stdint.h>
 #include <string>
 #include <unordered_set>
@@ -75,4 +76,6 @@ private:
 	Status status_;
 };
 
+std::ostream &operator<<(std::ostream &out, const Request &r);
+
 } /* namespace libcamera */
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
index 5704972d86af..f630f0818cbd 100644
--- a/src/libcamera/request.cpp
+++ b/src/libcamera/request.cpp
@@ -594,4 +594,16 @@ std::string Request::toString() const
 	return ss.str();
 }
 
+/**
+ * \brief Insert a text representation of a Request into an output stream
+ * \param[in] out The output stream
+ * \param[in] r The Request
+ * \return The output stream \a out
+ */
+std::ostream &operator<<(std::ostream &out, const Request &r)
+{
+	out << r.toString();
+	return out;
+}
+
 } /* namespace libcamera */
-- 
2.35.1



More information about the libcamera-devel mailing list