[{"id":1886,"web_url":"https://patchwork.libcamera.org/comment/1886/","msgid":"<20190613144319.edftkyijgztosea7@uno.localdomain>","date":"2019-06-13T14:43:19","subject":"Re: [libcamera-devel] [PATCH v2 03/16] libcamera: geometry:\n\tSizeRange: Add toString()","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hello,\n\nOn Wed, Jun 12, 2019 at 02:43:46AM +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> ---\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 c56c4e399ef307f5..6a1d1d78870b23ec 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\nI should have replied to the v1 comments, and this is so minor you can\nignore it, but since it's a range of sizes I would use square brakets in\nplace of '(' when printing out the minimum and maximum sizes.\n\nPatch's fine, feel free to ignore\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\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\n> --\n> 2.21.0\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1E2C561901\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Jun 2019 16:42:08 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id A0D446000F;\n\tThu, 13 Jun 2019 14:42:05 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Thu, 13 Jun 2019 16:43:19 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190613144319.edftkyijgztosea7@uno.localdomain>","References":"<20190612004359.15772-1-niklas.soderlund@ragnatech.se>\n\t<20190612004359.15772-4-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"zshhbukjhz2pk36n\"","Content-Disposition":"inline","In-Reply-To":"<20190612004359.15772-4-niklas.soderlund@ragnatech.se>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v2 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":"Thu, 13 Jun 2019 14:42:08 -0000"}}]