Patch Detail
Show a patch.
GET /api/1.1/patches/818/?format=api
{ "id": 818, "url": "https://patchwork.libcamera.org/api/1.1/patches/818/?format=api", "web_url": "https://patchwork.libcamera.org/patch/818/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190327002107.24487-3-niklas.soderlund@ragnatech.se>", "date": "2019-03-27T00:21:06", "name": "[libcamera-devel,v2,2/3] cam: options: Add an array data type to OptionValue", "commit_ref": "2a608965f8cb4bb93522e9b22af840c688ec12a1", "pull_url": null, "state": "accepted", "archived": false, "hash": "1b55800cd04d89037b6db4d99844fb09dfe16bc4", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/818/mbox/", "series": [ { "id": 221, "url": "https://patchwork.libcamera.org/api/1.1/series/221/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=221", "date": "2019-03-27T00:21:05", "name": "cam: options: Add support for repeatable options", "version": 2, "mbox": "https://patchwork.libcamera.org/series/221/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/818/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/818/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B918961111\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Mar 2019 01:21:22 +0100 (CET)", "from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid 38297868-5026-11e9-8144-0050569116f7;\n\tWed, 27 Mar 2019 01:21:09 +0100 (CET)" ], "X-Halon-ID": "38297868-5026-11e9-8144-0050569116f7", "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": "Wed, 27 Mar 2019 01:21:06 +0100", "Message-Id": "<20190327002107.24487-3-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190327002107.24487-1-niklas.soderlund@ragnatech.se>", "References": "<20190327002107.24487-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 2/3] cam: options: Add an array data\n\ttype 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": "Wed, 27 Mar 2019 00:21:23 -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 instead of\nsetting values using the constructor a new add() method is used.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/cam/options.cpp | 22 ++++++++++++++++++++++\n src/cam/options.h | 7 +++++++\n 2 files changed, 29 insertions(+)", "diff": "diff --git a/src/cam/options.cpp b/src/cam/options.cpp\nindex 497833397d894f82..556e7623c54b0658 100644\n--- a/src/cam/options.cpp\n+++ b/src/cam/options.cpp\n@@ -5,6 +5,7 @@\n * options.cpp - cam - Options parsing\n */\n \n+#include <cassert>\n #include <getopt.h>\n #include <iomanip>\n #include <iostream>\n@@ -272,6 +273,14 @@ OptionValue::OptionValue(const KeyValueParser::Options &value)\n {\n }\n \n+void OptionValue::addValue(const OptionValue &value)\n+{\n+\tassert(type_ == ValueNone || type_ == ValueArray);\n+\n+\ttype_ = ValueArray;\n+\tarray_.push_back(value);\n+}\n+\n OptionValue::operator int() const\n {\n \treturn toInteger();\n@@ -287,6 +296,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 +325,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..e0ff50af2fa74986 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@@ -92,21 +94,26 @@ public:\n \tOptionValue(const std::string &value);\n \tOptionValue(const KeyValueParser::Options &value);\n \n+\tvoid addValue(const OptionValue &value);\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", "v2", "2/3" ] }