[{"id":1911,"web_url":"https://patchwork.libcamera.org/comment/1911/","msgid":"<20190618222357.GI23556@pendragon.ideasonboard.com>","date":"2019-06-18T22:23:57","subject":"Re: [libcamera-devel] [PATCH v3 03/16] libcamera: geometry:\n\tSizeRange: Add toString()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Sun, Jun 16, 2019 at 03:33:49PM +0200, Niklas Söderlund wrote:\n> It's useful to be able to print a string representation of a SizeRange\n> to the log or console, add a toString() method. While at it turn the\n> structure into a class as it contains functions as well as data.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  include/libcamera/geometry.h |  6 +++++-\n>  src/libcamera/geometry.cpp   | 14 ++++++++++++++\n>  2 files changed, 19 insertions(+), 1 deletion(-)\n> \n> diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\n> index b2a8e5b0e005e4db..03962d7d09fac2b0 100644\n> --- a/include/libcamera/geometry.h\n> +++ b/include/libcamera/geometry.h\n> @@ -67,7 +67,9 @@ static inline bool operator>=(const Size &lhs, const Size &rhs)\n>  \treturn !(lhs < rhs);\n>  }\n>  \n> -struct SizeRange {\n> +class SizeRange\n> +{\n> +public:\n>  \tSizeRange()\n>  \t{\n>  \t}\n> @@ -90,6 +92,8 @@ struct SizeRange {\n>  \t{\n>  \t}\n>  \n> +\tstd::string toString() const;\n> +\n>  \tSize min;\n>  \tSize max;\n>  \tunsigned int hStep;\n> diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\n> index dfc264b2700f7f61..895861eb0678181b 100644\n> --- a/src/libcamera/geometry.cpp\n> +++ b/src/libcamera/geometry.cpp\n> @@ -261,6 +261,20 @@ bool operator<(const Size &lhs, const Size &rhs)\n>   * \\brief The vertical step\n>   */\n>  \n> +/**\n> + * \\brief Assemble and return a string describing the size range\n> + * \\return A string describing the SizeRange\n> + */\n> +std::string SizeRange::toString() const\n> +{\n> +\tstd::stringstream ss;\n> +\n> +\tss << \"(\" << min.toString() << \")-(\" << max.toString() << \")/(+\"\n> +\t   << hStep << \",+\" << vStep << \")\";\n> +\n> +\treturn ss.str();\n> +}\n> +\n>  /**\n>   * \\brief Compare size ranges for equality\n>   * \\return True if the two size ranges are equal, false otherwise","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F06F60BE4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Jun 2019 00:24:15 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9E065D5;\n\tWed, 19 Jun 2019 00:24:14 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1560896654;\n\tbh=ni45BjDlGfHlNhKGtqKZxwsrDiBddQyD2bOpHWKVyyY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=glBlcWcW8hgHGiyCymnneFtil7AHMSrOmhVyOQQJjkLPxqt5j4Pf9B4S0ZEf8JHrd\n\tXr2GPNfUvm7F5l7y/LyyyVFz2iSge5h/t6KxUixUkF6lJNSbyrq2srGYoTyxekJgzW\n\tYpAMUI+aqikEis0jwHPHC6VlQiaCSf2JGBPPop3k=","Date":"Wed, 19 Jun 2019 01:23:57 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190618222357.GI23556@pendragon.ideasonboard.com>","References":"<20190616133402.21934-1-niklas.soderlund@ragnatech.se>\n\t<20190616133402.21934-4-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190616133402.21934-4-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 03/16] libcamera: geometry:\n\tSizeRange: Add toString()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 18 Jun 2019 22:24:15 -0000"}}]