Patch Detail
Show a patch.
GET /api/1.1/patches/16824/?format=api
{ "id": 16824, "url": "https://patchwork.libcamera.org/api/1.1/patches/16824/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16824/", "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": "<20220727023816.30008-14-laurent.pinchart@ideasonboard.com>", "date": "2022-07-27T02:38:15", "name": "[libcamera-devel,v7,13/14] libcamera: yaml_parser: Add getList() function", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "1c8e55f067c22a3e238b304bac6c4c6432fb2a69", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16824/mbox/", "series": [ { "id": 3331, "url": "https://patchwork.libcamera.org/api/1.1/series/3331/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3331", "date": "2022-07-27T02:38:02", "name": "Replace boost JSON parser with libyaml in Raspberry Pi IPA", "version": 7, "mbox": "https://patchwork.libcamera.org/series/3331/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16824/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16824/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 6EECCC3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 27 Jul 2022 02:38:38 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1B70963335;\n\tWed, 27 Jul 2022 04:38:38 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 85F516332C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Jul 2022 04:38:34 +0200 (CEST)", "from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E0F5835;\n\tWed, 27 Jul 2022 04:38:34 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658889518;\n\tbh=4ogMDBF/JMuX5fNaBX1VqNSXwS84vBW27QFVWyEaRAo=;\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=swTyZTAk/g85AfmVOEkBBl6xJFTvWdTBj3N7Qf2mD2aONRdG5fIepNbMPTWhEQ4BF\n\tzhmsboIevWEOFArgKTWeHHcAoykAsCLnUg+09TfmyHGoVQ6gp3FyK9tI2kt68Ey9jd\n\tnqK39s4/54L1RZg0fI2qJWIke2OPjdBom44EY++9LYB0Rw7JMbGNFw1/FnrTW7eu2S\n\tOi2h0bnuSpNd6heAAj+57xf2HshXwgv8yrRKSar7kbwLrhNVPE1Yvv3ihdnkRZqacM\n\t5B+rKFBP1OLn2HEsboN9pxFitKWV82mm1QqRdZEd1bYYxit0enJIMYnkkqGudUzJpV\n\t5DKImD6OFhyMw==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658889514;\n\tbh=4ogMDBF/JMuX5fNaBX1VqNSXwS84vBW27QFVWyEaRAo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=c96tIMyGCLCbNI9n0/P5NFg5ZU3K5e/uDPK3RZG92l7FS9qPTntvgoAv0Kc6zO4yQ\n\tIsB+rGF+61m3CoUtWoU04ytzmLtDBKJEZkKXAhPgB//l3ZBcKrMqfVrkJYdgZcVdvK\n\tMF/53Lv/lEmdthGzTAujqqerkCOVw5isZ/JmcEt0=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"c96tIMyG\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 27 Jul 2022 05:38:15 +0300", "Message-Id": "<20220727023816.30008-14-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.35.1", "In-Reply-To": "<20220727023816.30008-1-laurent.pinchart@ideasonboard.com>", "References": "<20220727023816.30008-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v7 13/14] 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": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: Florian Sylvestre <fsylvestre@baylibre.com>\n\nAllow to retrieve a YAML list of any already supported types in a\nstd::vector.\n\nSigned-off-by: Florian Sylvestre <fsylvestre@baylibre.com>\n---\n include/libcamera/internal/yaml_parser.h | 16 +++++++\n src/libcamera/yaml_parser.cpp | 53 ++++++++++++++++++++++++\n test/yaml-parser.cpp | 6 +++\n 3 files changed, 75 insertions(+)", "diff": "diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\nindex 9c85d26a2a88..78c359f749bf 100644\n--- a/include/libcamera/internal/yaml_parser.h\n+++ b/include/libcamera/internal/yaml_parser.h\n@@ -183,6 +183,22 @@ public:\n \t\treturn get<T>().value_or(defaultValue);\n \t}\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::optional<std::vector<T>> getList() const;\n+\n \tDictAdapter asDict() const { return DictAdapter{ list_ }; }\n \tListAdapter asList() const { return ListAdapter{ list_ }; }\n \ndiff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\nindex 89c234fbbce5..440e35c47cab 100644\n--- a/src/libcamera/yaml_parser.cpp\n+++ b/src/libcamera/yaml_parser.cpp\n@@ -292,6 +292,59 @@ std::optional<Size> YamlObject::get() const\n \n #endif /* __DOXYGEN__ */\n \n+/**\n+ * \\fn template<typename T> YamlObject::getList<T>() const\n+ * \\brief Parse the YamlObject as a list of \\a T\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, std::nullopt\n+ * is returned.\n+ *\n+ * \\return The YamlObject value as a std::vector<T>, or std::nullopt if parsing\n+ * failed\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::optional<std::vector<T>> YamlObject::getList() const\n+{\n+\tif (type_ != Type::List)\n+\t\treturn {};\n+\n+\tstd::vector<T> values;\n+\tvalues.reserve(list_.size());\n+\n+\tfor (const YamlObject &entry : asList()) {\n+\t\tconst auto value = entry.get<T>();\n+\t\tif (!value)\n+\t\t\treturn {};\n+\t\tvalues.emplace_back(*value);\n+\t}\n+\n+\treturn values;\n+}\n+\n+template std::optional<std::vector<bool>> YamlObject::getList<bool>() const;\n+template std::optional<std::vector<double>> YamlObject::getList<double>() const;\n+template std::optional<std::vector<int16_t>> YamlObject::getList<int16_t>() const;\n+template std::optional<std::vector<uint16_t>> YamlObject::getList<uint16_t>() const;\n+template std::optional<std::vector<int32_t>> YamlObject::getList<int32_t>() const;\n+template std::optional<std::vector<uint32_t>> YamlObject::getList<uint32_t>() const;\n+template std::optional<std::vector<std::string>> YamlObject::getList<std::string>() const;\n+template std::optional<std::vector<Size>> YamlObject::getList<Size>() 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 782331764346..9fd278664b3b 100644\n--- a/test/yaml-parser.cpp\n+++ b/test/yaml-parser.cpp\n@@ -518,6 +518,12 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\tconst auto &values = firstElement.getList<uint16_t>();\n+\t\tif (!values || 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", "v7", "13/14" ] }