From patchwork Tue Mar 26 08:38:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 799 Return-Path: Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 85989611A7 for ; Tue, 26 Mar 2019 09:38:32 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 12826240014; Tue, 26 Mar 2019 08:38:31 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Mar 2019 09:38:47 +0100 Message-Id: <20190326083902.26121-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190326083902.26121-1-jacopo@jmondi.org> References: <20190326083902.26121-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 04/19] libcamera: geometry: Add toString to Rectangle X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2019 08:38:32 -0000 Add toString() helpers to pretty print out the sizes of a Rectangle. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/geometry.cpp | 16 ++++++++++++++++ src/libcamera/include/geometry.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index dbc37ca8e3f4..f76001d94562 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -5,6 +5,8 @@ * geometry.cpp - Geometry-related structures */ +#include + #include "geometry.h" /** @@ -46,6 +48,20 @@ namespace libcamera { * \brief The distance between the top and bottom sides */ +/** + * \brief Assemble and return a string describing the rectangle + * + * \return A string describing the Rectangle + */ +const std::string Rectangle::toString() const +{ + std::stringstream ss; + + ss << "(" << x << "x" << y << ")/" << w << "x" << h; + + return ss.str(); +} + /** * \struct SizeRange * \brief Describe a range of image sizes diff --git a/src/libcamera/include/geometry.h b/src/libcamera/include/geometry.h index 749746495204..567a54299b24 100644 --- a/src/libcamera/include/geometry.h +++ b/src/libcamera/include/geometry.h @@ -8,6 +8,8 @@ #ifndef __LIBCAMERA_GEOMETRY_H__ #define __LIBCAMERA_GEOMETRY_H__ +#include + namespace libcamera { struct Rectangle { @@ -15,6 +17,8 @@ struct Rectangle { int y; unsigned int w; unsigned int h; + + const std::string toString() const; }; struct SizeRange {