[{"id":18122,"web_url":"https://patchwork.libcamera.org/comment/18122/","msgid":"<f0e29d41-cff6-fbd7-4f53-1dcbf8ee543f@ideasonboard.com>","date":"2021-07-12T15:08:34","subject":"Re: [libcamera-devel] [PATCH 10/30] cam: options: Drop some\n\tOptionValue cast operators","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"On 07/07/2021 03:19, Laurent Pinchart wrote:\n> While OptionValue cast operators to int and std::string allow useful\n> shortcut syntaxes, the cast operators to KeyValueParser::Options and\n> std::vector<OptionValue> are less useful. A an explicit static_cast call\n> would be more cumbersome to write than an explicit .toKeyValues() or\n> toArray(), and implicit cast hide too much of what's going on.\n> \n> Drop those two cast operators, and replace the only implicit cast\n> occurrence with .toKeyValues(). While at it, drop the local opts\n> variable in StreamKeyValueParser::roles() as it isn't used.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/cam/options.cpp        | 20 --------------------\n>  src/cam/options.h          |  2 --\n>  src/cam/stream_options.cpp |  3 +--\n>  3 files changed, 1 insertion(+), 24 deletions(-)\n> \n> diff --git a/src/cam/options.cpp b/src/cam/options.cpp\n> index d7f9f741c731..319fab6143c5 100644\n> --- a/src/cam/options.cpp\n> +++ b/src/cam/options.cpp\n> @@ -604,26 +604,6 @@ OptionValue::operator std::string() const\n>  \treturn toString();\n>  }\n>  \n> -/**\n> - * \\brief Cast the value to a key-value list\n> - * \\return The option value as a KeyValueParser::Options, or an empty list if\n> - * the value type isn't ValueType::ValueKeyValue\n> - */\n> -OptionValue::operator KeyValueParser::Options() const\n> -{\n> -\treturn toKeyValues();\n> -}\n> -\n> -/**\n> - * \\brief Cast the value to an array\n> - * \\return The option value as a std::vector of OptionValue, or an empty vector\n> - * if the value type isn't ValueType::ValueArray\n> - */\n> -OptionValue::operator std::vector<OptionValue>() const\n> -{\n> -\treturn toArray();\n> -}\n> -\n>  /**\n>   * \\brief Retrieve the value as an int\n>   * \\return The option value as an int, or 0 if the value type isn't\n> diff --git a/src/cam/options.h b/src/cam/options.h\n> index e894822c0061..210e502a24e1 100644\n> --- a/src/cam/options.h\n> +++ b/src/cam/options.h\n> @@ -138,8 +138,6 @@ public:\n>  \n>  \toperator int() const;\n>  \toperator std::string() const;\n> -\toperator KeyValueParser::Options() const;\n> -\toperator std::vector<OptionValue>() const;\n>  \n>  \tint toInteger() const;\n>  \tstd::string toString() const;\n> diff --git a/src/cam/stream_options.cpp b/src/cam/stream_options.cpp\n> index c58272c23d25..b90dbb97f087 100644\n> --- a/src/cam/stream_options.cpp\n> +++ b/src/cam/stream_options.cpp\n> @@ -48,11 +48,10 @@ StreamRoles StreamKeyValueParser::roles(const OptionValue &values)\n>  \n>  \tStreamRoles roles;\n>  \tfor (auto const &value : streamParameters) {\n> -\t\tKeyValueParser::Options opts = value.toKeyValues();\n>  \t\tStreamRole role;\n>  \n>  \t\t/* If role is invalid or not set default to viewfinder. */\n> -\t\tif (!parseRole(&role, value))\n> +\t\tif (!parseRole(&role, value.toKeyValues()))\n>  \t\t\trole = StreamRole::Viewfinder;\n>  \n>  \t\troles.push_back(role);\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 676BCC3225\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Jul 2021 15:08:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 73C9C68513;\n\tMon, 12 Jul 2021 17:08:39 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7FECA68513\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Jul 2021 17:08:37 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BAA99CC;\n\tMon, 12 Jul 2021 17:08:36 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"NkjlguB2\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626102516;\n\tbh=xo49KOH+DVC1dKBbREAMDRpTT9xfoC48osqWab7sRZM=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=NkjlguB2Gkez21A5Cz58P5ctu4q0oFYuJ9/qA9QSTTLRqAZCDXM+dmiCUG6o5slNW\n\t53P9bUqOEwB07goEDapK10zSh48bRjrWi6ElgAjJf6CZkRRf+VaNPXEbC2VN954o7V\n\tr7EgAgmfEBz2OtMbK5J1l9s2G9bw8HOfZ+IHVFBg=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210707021941.20804-1-laurent.pinchart@ideasonboard.com>\n\t<20210707021941.20804-11-laurent.pinchart@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<f0e29d41-cff6-fbd7-4f53-1dcbf8ee543f@ideasonboard.com>","Date":"Mon, 12 Jul 2021 16:08:34 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<20210707021941.20804-11-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH 10/30] cam: options: Drop some\n\tOptionValue cast operators","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]