Patch Detail
Show a patch.
GET /api/1.1/patches/16796/?format=api
{ "id": 16796, "url": "https://patchwork.libcamera.org/api/1.1/patches/16796/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16796/", "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": "<20220726143635.518227-2-fsylvestre@baylibre.com>", "date": "2022-07-26T14:36:31", "name": "[libcamera-devel,v3,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/16796/mbox/", "series": [ { "id": 3328, "url": "https://patchwork.libcamera.org/api/1.1/series/3328/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3328", "date": "2022-07-26T14:36:30", "name": "Add GSL, LSC and DPCC tuning support for rkisp1", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3328/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16796/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16796/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 CC9F3C3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Jul 2022 14:36:44 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 83D5563317;\n\tTue, 26 Jul 2022 16:36:44 +0200 (CEST)", "from mail-wm1-x333.google.com (mail-wm1-x333.google.com\n\t[IPv6:2a00:1450:4864:20::333])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5592760487\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Jul 2022 16:36:41 +0200 (CEST)", "by mail-wm1-x333.google.com with SMTP id\n\tf24-20020a1cc918000000b003a30178c022so11466186wmb.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Jul 2022 07:36:41 -0700 (PDT)", "from BL087.. ([2a01:e34:eea9:e630:c7b2:2183:8a06:b4dc])\n\tby smtp.gmail.com with ESMTPSA id\n\tm184-20020a1c26c1000000b003a04722d745sm22447386wmm.23.2022.07.26.07.36.39\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 26 Jul 2022 07:36:39 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658846204;\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=dL/TwfMSRkChwZsEDipfDx7sU3VzsMPCT2E9QTotPZrL39W3+ZJUdshPBDye87ZZY\n\t2nPMhi56zM8v/FGDkA96rh1XPHIg7AdRY0pDSCJJc5zYTwPPQsnssw7F+iDTNYFCkc\n\tVjBufK/GyKt6cWHF99gGfLQkKiHAaR7v6gtpcovMyqahbgv0sJ2lf700qpeLUsoyER\n\t/e5wjC102dsQD+Uy4pRTeSKwU596xfy9VIEn/n29YgQYptO4z37rooj/Qnf3AIvm8D\n\tACsNQpN+SOGh+TTqb2BKbsJFvNxEsfO5bXi3+MGhofu8Zr9AYlicuYo+4QP6QPhWKe\n\tjb5hf/xMUNuVA==", "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=q8sKAL3VHLZ+NStg4Ilpqy3UCYTLd/9viY1WBZwHiNKPODj722mJ5avFu0A97r+Su6\n\tagCSQkDa6wHB/qtBHnoVYyhM+jikmhrF2DcadFn5ea/b8L+DdOYiBaQlhYZ5xzVi4xH1\n\teXD4Zoenrd9ORMHw0h/HXPv5MH1DooTK+3PurlevKy8Nr0qG46Y16Oq/MaIa9uHVQgN8\n\tuvQ5eCjjGUMXMB0U7W01R7fmYAqqasg0Ouk8puHdkgm2v1eLX9aFh/cB5dRuYxc/zAdc\n\tnGY53ZyXMUr4WPOVi1KJhrBy+dl3KA4Sg1itj7/Nw4xjjAwWIxqDWWLyoQ6izpKoSWUr\n\t+6gw==" ], "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=\"q8sKAL3V\"; \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=k2A9U130roJbohcGQ0B7THn51ERMTiymvRm1STfhCcwUSt17heL2KJThrQr3vsUAys\n\t5foO0SAXJ4nCwH3JpxZFmZOK7+OkauNYLkisGKltVaUIa831/0ss1aIASqD6FeGYxzwQ\n\tVwVL2qcG1RSJh8zpAfmvrCMwjvAxpfIB8SEHir2/74zPE0E/JJfb4y1lGDkTSuHCeXlR\n\tj+g6BEC8Z09Kj6zsp5j/WW1Ql7Wue7vAFczJ02qQ9fW+Pf3QuUyidyXLXHBMTQihgvlO\n\tNO3oDsS5utLCVtz8EkOQLiYCFqT9HDs0gpwv3Y3Q+BzwoyAi7pB4TU8YnICSt6c3FfzZ\n\tYiRw==", "X-Gm-Message-State": "AJIora8nXmn3dGT2XcVysno4/WlhxbNFR8kk5e+vzzVLuRmrLPSrVH0s\n\tLX03aRQemaVGpwCEkV7KCmdCM2/1oOKyX3jj", "X-Google-Smtp-Source": "AGRyM1t548SvY6kwjYjp/tf5lzhT/HnYf4FXqI/8UMzchJ1Ygmrwu2UjTJgnB37nzhD68S9+rNA3Kw==", "X-Received": "by 2002:a05:600c:3d93:b0:3a3:3a93:fb16 with SMTP id\n\tbi19-20020a05600c3d9300b003a33a93fb16mr16946782wmb.190.1658846200504; \n\tTue, 26 Jul 2022 07:36:40 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 26 Jul 2022 16:36:31 +0200", "Message-Id": "<20220726143635.518227-2-fsylvestre@baylibre.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220726143635.518227-1-fsylvestre@baylibre.com>", "References": "<20220726143635.518227-1-fsylvestre@baylibre.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 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", "v3", "1/5" ] }