[{"id":735,"web_url":"https://patchwork.libcamera.org/comment/735/","msgid":"<20190201094028.GO19527@bigcity.dyn.berto.se>","date":"2019-02-01T09:40:28","subject":"Re: [libcamera-devel] [PATCH] cam: options: Add explicit conversion\n\tmethods to OptionValue","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your patch.\n\nOn 2019-02-01 11:29:19 +0200, Laurent Pinchart wrote:\n> The OptionValue class defines operators to convert the variant to all\n> the supported option types. As a convenience, add explicit methods to\n> perform the same operations, avoiding the need to write long\n> static_cast<>() statements in the caller.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/cam/options.cpp | 19 +++++++++++++++++--\n>  src/cam/options.h   |  4 ++++\n>  2 files changed, 21 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/cam/options.cpp b/src/cam/options.cpp\n> index 4c9f3a36d435..eb59376fa459 100644\n> --- a/src/cam/options.cpp\n> +++ b/src/cam/options.cpp\n> @@ -273,6 +273,21 @@ OptionValue::OptionValue(const KeyValueParser::Options &value)\n>  }\n>  \n>  OptionValue::operator int() const\n> +{\n> +\treturn toInteger();\n> +}\n> +\n> +OptionValue::operator std::string() const\n> +{\n> +\treturn toString();\n> +}\n> +\n> +OptionValue::operator KeyValueParser::Options() const\n> +{\n> +\treturn toKeyValues();\n> +}\n> +\n> +int OptionValue::toInteger() const\n>  {\n>  \tif (type_ != OptionInteger)\n>  \t\treturn 0;\n> @@ -280,7 +295,7 @@ OptionValue::operator int() const\n>  \treturn integer_;\n>  }\n>  \n> -OptionValue::operator std::string() const\n> +std::string OptionValue::toString() const\n>  {\n>  \tif (type_ != OptionString)\n>  \t\treturn std::string();\n> @@ -288,7 +303,7 @@ OptionValue::operator std::string() const\n>  \treturn string_;\n>  }\n>  \n> -OptionValue::operator KeyValueParser::Options() const\n> +KeyValueParser::Options OptionValue::toKeyValues() const\n>  {\n>  \tif (type_ != OptionKeyValue)\n>  \t\treturn KeyValueParser::Options();\n> diff --git a/src/cam/options.h b/src/cam/options.h\n> index e1fd62ecd369..2d3aa50b5051 100644\n> --- a/src/cam/options.h\n> +++ b/src/cam/options.h\n> @@ -91,6 +91,10 @@ public:\n>  \toperator std::string() const;\n>  \toperator KeyValueParser::Options() const;\n>  \n> +\tint toInteger() const;\n> +\tstd::string toString() const;\n> +\tKeyValueParser::Options toKeyValues() const;\n> +\n>  private:\n>  \tOptionType type_;\n>  \tint integer_;\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x243.google.com (mail-lj1-x243.google.com\n\t[IPv6:2a00:1450:4864:20::243])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3BD4A60C6A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  1 Feb 2019 10:40:38 +0100 (CET)","by mail-lj1-x243.google.com with SMTP id v1-v6so5262724ljd.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 01 Feb 2019 01:40:38 -0800 (PST)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\ta19sm1267585lfi.57.2019.02.01.01.40.28\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tFri, 01 Feb 2019 01:40:28 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=R9PJsazg3SwYZE0bq3Sqd550nlCYao2ksTllrKN8xbY=;\n\tb=sr6XWjzv3joBMky4wFP+li/7s74lcBFT3LichFXxmgxjK0zEqQdamI5X4mJl2Rm5+k\n\taR7uz42iEBd7Eff81wemkcZJvM37jKMvmrGP5/12udT4w605bt1M2nZ/8gCtO9Akc74u\n\t2eVJoFy0jhf8rp7vrjf9GTviK7KYBwd1rUYGeNY9INZ46ZXBZ3C/frRRVUSnIQnkUWLD\n\tCZax0RzH3j4VXJUms3oEM64TUKvEJjVuxiWVmTn8NyJ9JXE/8dfDX0ajUzGF2RX/PP6G\n\txIjSa1mmll/eAhAWUFvWPBUht1YCxFLfIrj7mfd2aSGT8d07L1xKBqNNSb7ZIUOevVBp\n\ta8Xw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=R9PJsazg3SwYZE0bq3Sqd550nlCYao2ksTllrKN8xbY=;\n\tb=DzMFo/6dYIgDmbFI6cyQ56xibUBAyWzriOx5nndsvTQE8RYWon6ztMURYbMlkjV8/o\n\tUz3LplSDSdDN5/oohFqCgEG6+2F0C3dx/s8MgzWJVgIGkdqXnm0vxlLDTlTdwTAbGeD7\n\tJvqAsL4flVfz/ht3uOrH197F1yOUj5OxbbPETCUcg6JcPppbCG34iDGboHu6YUFRbEVH\n\tpcLeXo6yAwM5HH6RC+/S6KrUvodv6rY/u/DAZUuS1V1Q629ze8n6N/jamcBf40q2aMHS\n\tj8aUG7n4UjZBH/Vq90RP3OHa4G/0QQD5//JXSDaaqWNkjsBK25I3C7gPMXtzLm4ZmoGk\n\tEcww==","X-Gm-Message-State":"AHQUAuZJZlIcXihAqyOx2u6/iPoeC31h8NKte3iYnmmdl5/8kAwre69e\n\tuviMi5kVE9sfysdhyzoul4jeNQ==","X-Google-Smtp-Source":"AHgI3IZNfF5FTSEV7k8KlVBEpM2J3tKgKBeiFkjblNy8eZWpqQ2zxpa2Ycdmrmkvwg12HmrUuedNyQ==","X-Received":"by 2002:a2e:9694:: with SMTP id\n\tq20-v6mr19041534lji.173.1549014029331; \n\tFri, 01 Feb 2019 01:40:29 -0800 (PST)","Date":"Fri, 1 Feb 2019 10:40:28 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190201094028.GO19527@bigcity.dyn.berto.se>","References":"<20190201092919.8336-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190201092919.8336-1-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH] cam: options: Add explicit conversion\n\tmethods to OptionValue","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":"Fri, 01 Feb 2019 09:40:38 -0000"}}]