{"id":780,"url":"https://patchwork.libcamera.org/api/patches/780/?format=json","web_url":"https://patchwork.libcamera.org/patch/780/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190322015349.14934-3-niklas.soderlund@ragnatech.se>","date":"2019-03-22T01:53:47","name":"[libcamera-devel,RFC,2/4] cam: options: Add an array data type to OptionValue","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"58469d62b5e0e10c3d468a21694ba7a4aea3133e","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/780/mbox/","series":[{"id":215,"url":"https://patchwork.libcamera.org/api/series/215/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=215","date":"2019-03-22T01:53:45","name":"cam: Extend to support configuration of multiple streams","version":1,"mbox":"https://patchwork.libcamera.org/series/215/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/780/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/780/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BECB36110A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Mar 2019 02:54:07 +0100 (CET)","from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 600d7062-4c45-11e9-985a-005056917f90;\n\tFri, 22 Mar 2019 02:54:06 +0100 (CET)"],"X-Halon-ID":"600d7062-4c45-11e9-985a-005056917f90","Authorized-sender":"niklas@soderlund.pp.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 22 Mar 2019 02:53:47 +0100","Message-Id":"<20190322015349.14934-3-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190322015349.14934-1-niklas.soderlund@ragnatech.se>","References":"<20190322015349.14934-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC 2/4] cam: options: Add an array data type to\n\tOptionValue","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, 22 Mar 2019 01:54:08 -0000"},"content":"To allow specifying the same argument option multiple times a new type\nof OptionValue is needed. As parsing of options is an iterative process\nthere is a need to append options as they are parsed so a more complex\nconstructor us needed which can combine already stored instances of an\noption with new ones.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/cam/options.cpp | 21 +++++++++++++++++++++\n src/cam/options.h   |  6 ++++++\n 2 files changed, 27 insertions(+)","diff":"diff --git a/src/cam/options.cpp b/src/cam/options.cpp\nindex 497833397d894f82..7995a9b359764ec7 100644\n--- a/src/cam/options.cpp\n+++ b/src/cam/options.cpp\n@@ -272,6 +272,14 @@ OptionValue::OptionValue(const KeyValueParser::Options &value)\n {\n }\n \n+OptionValue::OptionValue(const OptionValue &value,\n+\t\t\t const std::vector<OptionValue> &array)\n+\t: type_(ValueArray)\n+{\n+\tarray_ = array;\n+\tarray_.push_back(value);\n+}\n+\n OptionValue::operator int() const\n {\n \treturn toInteger();\n@@ -287,6 +295,11 @@ OptionValue::operator KeyValueParser::Options() const\n \treturn toKeyValues();\n }\n \n+OptionValue::operator std::vector<OptionValue>() const\n+{\n+\treturn toArray();\n+}\n+\n int OptionValue::toInteger() const\n {\n \tif (type_ != ValueInteger)\n@@ -311,6 +324,14 @@ KeyValueParser::Options OptionValue::toKeyValues() const\n \treturn keyValues_;\n }\n \n+std::vector<OptionValue> OptionValue::toArray() const\n+{\n+\tif (type_ != ValueArray)\n+\t\treturn std::vector<OptionValue>{};\n+\n+\treturn array_;\n+}\n+\n /* -----------------------------------------------------------------------------\n  * OptionsParser\n  */\ndiff --git a/src/cam/options.h b/src/cam/options.h\nindex b33a90fc6058febf..789ba36187dd1fc3 100644\n--- a/src/cam/options.h\n+++ b/src/cam/options.h\n@@ -10,6 +10,7 @@\n #include <ctype.h>\n #include <list>\n #include <map>\n+#include <vector>\n \n class KeyValueParser;\n class OptionValue;\n@@ -84,6 +85,7 @@ public:\n \t\tValueInteger,\n \t\tValueString,\n \t\tValueKeyValue,\n+\t\tValueArray,\n \t};\n \n \tOptionValue();\n@@ -91,22 +93,26 @@ public:\n \tOptionValue(const char *value);\n \tOptionValue(const std::string &value);\n \tOptionValue(const KeyValueParser::Options &value);\n+\tOptionValue(const OptionValue &value, const std::vector<OptionValue> &array);\n \n \tValueType type() const { return type_; }\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 \tKeyValueParser::Options toKeyValues() const;\n+\tstd::vector<OptionValue> toArray() const;\n \n private:\n \tValueType type_;\n \tint integer_;\n \tstd::string string_;\n \tKeyValueParser::Options keyValues_;\n+\tstd::vector<OptionValue> array_;\n };\n \n class OptionsParser\n","prefixes":["libcamera-devel","RFC","2/4"]}