Patch Detail
Show a patch.
GET /api/1.1/patches/16832/?format=api
{ "id": 16832, "url": "https://patchwork.libcamera.org/api/1.1/patches/16832/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16832/", "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": "<20220727084052.590421-2-fsylvestre@baylibre.com>", "date": "2022-07-27T08:40:48", "name": "[libcamera-devel,v4,1/5] libcamera: yaml_parser: Add getList() function", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "d8477110ef5f9d748a351037de353a3a9e0117b5", "submitter": { "id": 123, "url": "https://patchwork.libcamera.org/api/1.1/people/123/?format=api", "name": "Florian Sylvestre", "email": "fsylvestre@baylibre.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16832/mbox/", "series": [ { "id": 3334, "url": "https://patchwork.libcamera.org/api/1.1/series/3334/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3334", "date": "2022-07-27T08:40:47", "name": "Add GSL, LSC and DPCC tuning support for rkisp1", "version": 4, "mbox": "https://patchwork.libcamera.org/series/3334/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16832/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16832/checks/", "tags": {}, "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 F2589BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 27 Jul 2022 08:41:01 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A34C563316;\n\tWed, 27 Jul 2022 10:41:01 +0200 (CEST)", "from mail-wr1-x432.google.com (mail-wr1-x432.google.com\n\t[IPv6:2a00:1450:4864:20::432])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 782CA6330E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Jul 2022 10:40:59 +0200 (CEST)", "by mail-wr1-x432.google.com with SMTP id v17so4256780wrr.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Jul 2022 01:40:59 -0700 (PDT)", "from BL087.. ([2a01:e34:eea9:e630:5810:316e:87c:fc17])\n\tby smtp.gmail.com with ESMTPSA id\n\t16-20020a05600c241000b003a2f6367049sm1464275wmp.48.2022.07.27.01.40.57\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 27 Jul 2022 01:40:58 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658911261;\n\tbh=/pk7XbtkUYawi0j+LgzQKVNqxB0MC9D4ZRM3xUTk++c=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Vo+7mdSfuzbcxiXuDmsTQcVVX4OzV1Lg6XNfC5hc92RMu04dnqsVHZ9lBUUdIgUI3\n\tVP3+7rmKZaKUIitRIhrnhX9de3F3zqhJas6YDHCn5lz5n1GiloCWPIGTpdrBbJcZOS\n\t7FHthtSlWaWPbFZnK+L71JAVYVjPHJtOV1wWadELjJHF/YsMViArEeXavWyFCzKWmN\n\tuI1OZNfqQKSmDGWiW67MtDIwUv843pMGsqeMGKCUQ/HxI6cxkvlg299f47gsEByQl8\n\tIESw17BwZUzw8bIkmxjvOgMDBB+jqC1rOyUVJ1O4C/gajVA/FdW63RRaZcaBV1GVZk\n\tdiQkS8+HnDODQ==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20210112.gappssmtp.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=K8KcnQjbTB/EoE6YznZHrFHtKHxZ0/IUQtG7YIMQdnY=;\n\tb=UIbIWAejOPVxG8hVfMMKNF5pOgskuWsjXEqlarm9J3DvMJNWxERJpz9Z1K9zHyEcy9\n\tvCMbqdh959vDANbFdSO2o25Jyilvt38hZRcvmtou00IYyN8BNVK7uu23Zl8ICfSAizwF\n\tHzhHpKwT5XoEEH74XiUbTWv91R13rwR662pzha+pIxeOt94OWue9o+X4zgF1+RQ/ij72\n\tBwGMOaMNsrhBrMyj4XjNzvKu7Ke2uWCxDVBb1E4JjYVnM+vSK8g7RUxqmYm/hYyHp0VX\n\txaMrTpwcNIEM7t9ZYNlc4PsKRCUcPt48LCdj3EZPGq6ppxx60zCgqLE8X0Iuwv7owStn\n\tPsqQ==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=baylibre-com.20210112.gappssmtp.com\n\theader.i=@baylibre-com.20210112.gappssmtp.com header.b=\"UIbIWAej\"; \n\tdkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=K8KcnQjbTB/EoE6YznZHrFHtKHxZ0/IUQtG7YIMQdnY=;\n\tb=B1DnWDYcUGYOSFO0OqAd1zVlT1RO7KGWniQHIdEN5TIRw3DP3CfLfkBoCMMJqdYr4a\n\tu1JZEM4DNSvbC4qZVkF6tcLS+Kw5K0I8MovD7XI7osY09a+sIxnZuC+0PFm/Wf28RG2d\n\tpj9G2swMWVzF1hI3rqNZ23BM1g2mBD1ip1iWJuvJ6tvxxl0yUnZvs+gv4rQx9GMY7cgi\n\thHWdHMwCgHbthvV5T1LeAnjVR9MORL0n/PTBqlb1gB/bWV739xKw6/Xzks8YRy8mnLr5\n\te1GwAWNqbDXVO3Erde+o+dUpt1Cey4djceUx8ooo/k0w/fjSaqokIA+9dn83Lid8+1eg\n\taqLw==", "X-Gm-Message-State": "AJIora8rexcssjTZ1qA6ZJiKmzx7o/8dq+q5RDi3qlAPZtgu5QNYxb9u\n\tkKopsF9tXQ54QBSMOPKwNHCpqRS+JGSIeBmF", "X-Google-Smtp-Source": "AGRyM1terR/08uqRIyMhMTTpkXqT7zppAfaYqEEaCjS2HwdPh9Bw8oH0blQINFbn20ATQbNsrrGyQw==", "X-Received": "by 2002:a05:6000:15c6:b0:21d:a96b:8ffd with SMTP id\n\ty6-20020a05600015c600b0021da96b8ffdmr14154970wry.610.1658911258568; \n\tWed, 27 Jul 2022 01:40:58 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 27 Jul 2022 10:40:48 +0200", "Message-Id": "<20220727084052.590421-2-fsylvestre@baylibre.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220727084052.590421-1-fsylvestre@baylibre.com>", "References": "<20220727084052.590421-1-fsylvestre@baylibre.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 1/5] libcamera: yaml_parser: Add\n\tgetList() function", "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>", "From": "Florian Sylvestre via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Florian Sylvestre <fsylvestre@baylibre.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Allow to retrieve a YAML list of any already supported types in a std::vector.\n\nSigned-off-by: Florian Sylvestre <fsylvestre@baylibre.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n include/libcamera/internal/yaml_parser.h | 16 ++++++\n src/libcamera/yaml_parser.cpp | 66 ++++++++++++++++++++++++\n test/yaml-parser.cpp | 6 +++\n 3 files changed, 88 insertions(+)", "diff": "diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\nindex 064cf443..39161bbb 100644\n--- a/include/libcamera/internal/yaml_parser.h\n+++ b/include/libcamera/internal/yaml_parser.h\n@@ -167,6 +167,22 @@ public:\n #endif\n \tT get(const T &defaultValue, bool *ok = nullptr) const;\n \n+#ifndef __DOXYGEN__\n+\ttemplate<typename T,\n+\t\t typename std::enable_if_t<\n+\t\t\t std::is_same_v<bool, T> ||\n+\t\t\t std::is_same_v<double, T> ||\n+\t\t\t std::is_same_v<int16_t, T> ||\n+\t\t\t std::is_same_v<uint16_t, T> ||\n+\t\t\t std::is_same_v<int32_t, T> ||\n+\t\t\t std::is_same_v<uint32_t, T> ||\n+\t\t\t std::is_same_v<std::string, T> ||\n+\t\t\t std::is_same_v<Size, T>> * = nullptr>\n+#else\n+\ttemplate<typename T>\n+#endif\n+\tstd::vector<T> getList(bool *ok = nullptr) const;\n+\n \tDictAdapter asDict() const { return DictAdapter{ dictionary_ }; }\n \tListAdapter asList() const { return ListAdapter{ list_ }; }\n \ndiff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\nindex 5c45e44e..125a348e 100644\n--- a/src/libcamera/yaml_parser.cpp\n+++ b/src/libcamera/yaml_parser.cpp\n@@ -325,6 +325,72 @@ Size YamlObject::get(const Size &defaultValue, bool *ok) const\n \n #endif /* __DOXYGEN__ */\n \n+/**\n+ * \\fn template<typename T> YamlObject::getList<T>(bool *ok) const\n+ * \\brief Parse the YamlObject as a list of \\a T\n+ * \\param[out] ok The result of whether the parse succeeded\n+ *\n+ * This function parses the value of the YamlObject as a list of \\a T objects,\n+ * and returns the value as a \\a std::vector<T>. If parsing fails \\a ok is set\n+ * to false and a default empty vector is returned. Otherwise, the\n+ * YamlObject list of values is returned, and \\a ok is set to true.\n+ *\n+ * The \\a ok pointer is optional and can be a nullptr if the caller doesn't\n+ * need to know if parsing succeeded.\n+ *\n+ * \\return Value as a std::vector<T> type\n+ */\n+\n+#ifndef __DOXYGEN__\n+\n+template<typename T,\n+\t typename std::enable_if_t<\n+\t\t std::is_same_v<bool, T> ||\n+\t\t std::is_same_v<double, T> ||\n+\t\t std::is_same_v<int16_t, T> ||\n+\t\t std::is_same_v<uint16_t, T> ||\n+\t\t std::is_same_v<int32_t, T> ||\n+\t\t std::is_same_v<uint32_t, T> ||\n+\t\t std::is_same_v<std::string, T> ||\n+\t\t std::is_same_v<Size, T>> *>\n+std::vector<T> YamlObject::getList(bool *ok) const\n+{\n+\tsetOk(ok, false);\n+\n+\tif (type_ != Type::List)\n+\t\treturn {};\n+\n+\tstd::vector<T> value;\n+\tvalue.reserve(list_.size());\n+\n+\t/*\n+\t * Provide somme dummy defaultValue to get() function and rely on the\n+\t * ok variable to know if the parsing was correct.\n+\t */\n+\tT defaultValue{};\n+\n+\tfor (const YamlObject &entry : asList()) {\n+\t\tbool result;\n+\t\tvalue.emplace_back(entry.get<T>(defaultValue, &result));\n+\t\tif (!result)\n+\t\t\treturn {};\n+\t}\n+\n+\tsetOk(ok, true);\n+\treturn value;\n+}\n+\n+template std::vector<bool> YamlObject::getList<bool>(bool *ok) const;\n+template std::vector<double> YamlObject::getList<double>(bool *ok) const;\n+template std::vector<int16_t> YamlObject::getList<int16_t>(bool *ok) const;\n+template std::vector<uint16_t> YamlObject::getList<uint16_t>(bool *ok) const;\n+template std::vector<int32_t> YamlObject::getList<int32_t>(bool *ok) const;\n+template std::vector<uint32_t> YamlObject::getList<uint32_t>(bool *ok) const;\n+template std::vector<std::string> YamlObject::getList<std::string>(bool *ok) const;\n+template std::vector<Size> YamlObject::getList<Size>(bool *ok) const;\n+\n+#endif /* __DOXYGEN__ */\n+\n /**\n * \\fn YamlObject::asDict() const\n * \\brief Wrap a dictionary YamlObject in an adapter that exposes iterators\ndiff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp\nindex 38f84823..bb96a11b 100644\n--- a/test/yaml-parser.cpp\n+++ b/test/yaml-parser.cpp\n@@ -524,6 +524,12 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\tstd::vector<uint16_t> values = firstElement.getList<uint16_t>();\n+\t\tif (values.size() != 2 || values[0] != 1 || values[1] != 2) {\n+\t\t\tcerr << \"getList() failed to return correct vector\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\tauto &secondElement = level2Obj[1];\n \t\tif (!secondElement.isDictionary() ||\n \t\t !secondElement.contains(\"one\") ||\n", "prefixes": [ "libcamera-devel", "v4", "1/5" ] }