[{"id":1116,"web_url":"https://patchwork.libcamera.org/comment/1116/","msgid":"<20190323142307.GK4587@pendragon.ideasonboard.com>","date":"2019-03-23T14:23:07","subject":"Re: [libcamera-devel] [RFC 1/4] cam: options: Create own enum for\n\tOptionValue types","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 Fri, Mar 22, 2019 at 02:53:46AM +0100, Niklas Söderlund wrote:\n> In preparation to add support specifying the same option multiple times\n\n\"In preparation for support of multiple instances of the same option,\"\n\n> create a own enum for the OptionValue types as it will diverge from the\n\nDid you mean \"a separate enum\" ?\n\n> one shared one.\n\none shared one ?\n\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/cam/options.cpp | 16 ++++++++--------\n>  src/cam/options.h   | 11 +++++++++--\n>  2 files changed, 17 insertions(+), 10 deletions(-)\n> \n> diff --git a/src/cam/options.cpp b/src/cam/options.cpp\n> index 655aa36bb9c93b85..497833397d894f82 100644\n> --- a/src/cam/options.cpp\n> +++ b/src/cam/options.cpp\n> @@ -248,27 +248,27 @@ void KeyValueParser::usage(int indent)\n>   */\n>  \n>  OptionValue::OptionValue()\n> -\t: type_(OptionNone)\n> +\t: type_(ValueNone)\n>  {\n>  }\n>  \n>  OptionValue::OptionValue(int value)\n> -\t: type_(OptionInteger), integer_(value)\n> +\t: type_(ValueInteger), integer_(value)\n>  {\n>  }\n>  \n>  OptionValue::OptionValue(const char *value)\n> -\t: type_(OptionString), string_(value)\n> +\t: type_(ValueString), string_(value)\n>  {\n>  }\n>  \n>  OptionValue::OptionValue(const std::string &value)\n> -\t: type_(OptionString), string_(value)\n> +\t: type_(ValueString), string_(value)\n>  {\n>  }\n>  \n>  OptionValue::OptionValue(const KeyValueParser::Options &value)\n> -\t: type_(OptionKeyValue), keyValues_(value)\n> +\t: type_(ValueKeyValue), keyValues_(value)\n>  {\n>  }\n>  \n> @@ -289,7 +289,7 @@ OptionValue::operator KeyValueParser::Options() const\n>  \n>  int OptionValue::toInteger() const\n>  {\n> -\tif (type_ != OptionInteger)\n> +\tif (type_ != ValueInteger)\n>  \t\treturn 0;\n>  \n>  \treturn integer_;\n> @@ -297,7 +297,7 @@ int OptionValue::toInteger() const\n>  \n>  std::string OptionValue::toString() const\n>  {\n> -\tif (type_ != OptionString)\n> +\tif (type_ != ValueString)\n>  \t\treturn std::string();\n>  \n>  \treturn string_;\n> @@ -305,7 +305,7 @@ std::string OptionValue::toString() const\n>  \n>  KeyValueParser::Options OptionValue::toKeyValues() const\n>  {\n> -\tif (type_ != OptionKeyValue)\n> +\tif (type_ != ValueKeyValue)\n>  \t\treturn KeyValueParser::Options();\n>  \n>  \treturn keyValues_;\n> diff --git a/src/cam/options.h b/src/cam/options.h\n> index 745f4a4a3a433f9e..b33a90fc6058febf 100644\n> --- a/src/cam/options.h\n> +++ b/src/cam/options.h\n> @@ -79,13 +79,20 @@ private:\n>  class OptionValue\n>  {\n>  public:\n> +\tenum ValueType {\n> +\t\tValueNone,\n> +\t\tValueInteger,\n> +\t\tValueString,\n> +\t\tValueKeyValue,\n> +\t};\n> +\n>  \tOptionValue();\n>  \tOptionValue(int value);\n>  \tOptionValue(const char *value);\n>  \tOptionValue(const std::string &value);\n>  \tOptionValue(const KeyValueParser::Options &value);\n>  \n> -\tOptionType type() const { return type_; }\n> +\tValueType type() const { return type_; }\n>  \n>  \toperator int() const;\n>  \toperator std::string() const;\n> @@ -96,7 +103,7 @@ public:\n>  \tKeyValueParser::Options toKeyValues() const;\n>  \n>  private:\n> -\tOptionType type_;\n> +\tValueType type_;\n>  \tint integer_;\n>  \tstd::string string_;\n>  \tKeyValueParser::Options keyValues_;","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EFEB2610B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 23 Mar 2019 15:23:20 +0100 (CET)","from pendragon.ideasonboard.com\n\t(p5269001-ipngn11702marunouchi.tokyo.ocn.ne.jp [114.158.195.1])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5C47D22;\n\tSat, 23 Mar 2019 15:23:18 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1553351000;\n\tbh=mK0o0cA9LDBrl28mC4FRVuUjttQuxohwkvK+wDLqjo0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=FueSjG4BHbjYOMPC05krontrgt3PLzM8KQzNjF8F71daPXJ0OFn6iGkDqQC2Twiir\n\tggZDyqkNRtKhTHyRtsM2GexmzbQlNSQuK485Xv4YZXPT/kaT+YbsrqCmdidODn1BSr\n\t+Uv0XAP2QTU/SFC4L5AZAyP9ThnU2as1/3BFwzus=","Date":"Sat, 23 Mar 2019 16:23:07 +0200","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":"<20190323142307.GK4587@pendragon.ideasonboard.com>","References":"<20190322015349.14934-1-niklas.soderlund@ragnatech.se>\n\t<20190322015349.14934-2-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":"<20190322015349.14934-2-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [RFC 1/4] cam: options: Create own enum for\n\tOptionValue types","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":"Sat, 23 Mar 2019 14:23:21 -0000"}}]