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>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ostream>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
@@ -50,4 +51,6 @@ private:
|
||||
uint32_t fourcc_;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const V4L2PixelFormat &f);
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ostream>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
@@ -45,4 +46,6 @@ private:
|
||||
uint64_t modifier_;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const PixelFormat &f);
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user