mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 15:29:45 +03:00
libcamera: geometry: Add operator<< for classes in geometry
Add operator<< for geometry classes for easier logging. Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
dd8b1723ac
commit
c730dc7479
2 changed files with 65 additions and 8 deletions
|
@ -46,6 +46,8 @@ static inline bool operator!=(const Point &lhs, const Point &rhs)
|
|||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const Point &p);
|
||||
|
||||
class Size
|
||||
{
|
||||
public:
|
||||
|
@ -192,6 +194,8 @@ static inline bool operator>=(const Size &lhs, const Size &rhs)
|
|||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const Size &s);
|
||||
|
||||
class SizeRange
|
||||
{
|
||||
public:
|
||||
|
@ -232,6 +236,8 @@ static inline bool operator!=(const SizeRange &lhs, const SizeRange &rhs)
|
|||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const SizeRange &sr);
|
||||
|
||||
class Rectangle
|
||||
{
|
||||
public:
|
||||
|
@ -291,4 +297,6 @@ static inline bool operator!=(const Rectangle &lhs, const Rectangle &rhs)
|
|||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const Rectangle &r);
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
|
|
@ -56,8 +56,7 @@ namespace libcamera {
|
|||
const std::string Point::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "(" << x << "," << y << ")";
|
||||
ss << *this;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
@ -83,6 +82,18 @@ bool operator==(const Point &lhs, const Point &rhs)
|
|||
* \return True if the two points are not equal, false otherwise
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Insert a text representation of a Point into an output stream
|
||||
* \param[in] out The output stream
|
||||
* \param[in] p The point
|
||||
* \return The output stream \a out
|
||||
*/
|
||||
std::ostream &operator<<(std::ostream &out, const Point &p)
|
||||
{
|
||||
out << "(" << p.x << ", " << p.y << ")";
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* \struct Size
|
||||
* \brief Describe a two-dimensional size
|
||||
|
@ -124,7 +135,10 @@ bool operator==(const Point &lhs, const Point &rhs)
|
|||
*/
|
||||
const std::string Size::toString() const
|
||||
{
|
||||
return std::to_string(width) + "x" + std::to_string(height);
|
||||
std::stringstream ss;
|
||||
ss << *this;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -428,6 +442,18 @@ bool operator<(const Size &lhs, const Size &rhs)
|
|||
* \sa bool operator<(const Size &lhs, const Size &rhs)
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Insert a text representation of a Size into an output stream
|
||||
* \param[in] out The output stream
|
||||
* \param[in] s The size
|
||||
* \return The output stream \a out
|
||||
*/
|
||||
std::ostream &operator<<(std::ostream &out, const Size &s)
|
||||
{
|
||||
out << s.width << "x" << s.height;
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* \struct SizeRange
|
||||
* \brief Describe a range of sizes
|
||||
|
@ -528,9 +554,7 @@ bool SizeRange::contains(const Size &size) const
|
|||
std::string SizeRange::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "(" << min.toString() << ")-(" << max.toString() << ")/(+"
|
||||
<< hStep << ",+" << vStep << ")";
|
||||
ss << *this;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
@ -550,6 +574,20 @@ bool operator==(const SizeRange &lhs, const SizeRange &rhs)
|
|||
* \return True if the two size ranges are not equal, false otherwise
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Insert a text representation of a SizeRange into an output stream
|
||||
* \param[in] out The output stream
|
||||
* \param[in] sr The size range
|
||||
* \return The output stream \a out
|
||||
*/
|
||||
std::ostream &operator<<(std::ostream &out, const SizeRange &sr)
|
||||
{
|
||||
out << "(" << sr.min << ")-(" << sr.max << ")/(+"
|
||||
<< sr.hStep << ",+" << sr.vStep << ")";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* \struct Rectangle
|
||||
* \brief Describe a rectangle's position and dimensions
|
||||
|
@ -624,8 +662,7 @@ bool operator==(const SizeRange &lhs, const SizeRange &rhs)
|
|||
const std::string Rectangle::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "(" << x << "x" << y << ")/" << width << "x" << height;
|
||||
ss << *this;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
@ -796,4 +833,16 @@ bool operator==(const Rectangle &lhs, const Rectangle &rhs)
|
|||
* \return True if the two rectangles are not equal, false otherwise
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Insert a text representation of a Rectangle into an output stream
|
||||
* \param[in] out The output stream
|
||||
* \param[in] r The rectangle
|
||||
* \return The output stream \a out
|
||||
*/
|
||||
std::ostream &operator<<(std::ostream &out, const Rectangle &r)
|
||||
{
|
||||
out << "(" << r.x << "x" << r.y << ")/" << r.width << "x" << r.height;
|
||||
return out;
|
||||
}
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue