Patch Detail
Show a patch.
GET /api/1.1/patches/16734/?format=api
{ "id": 16734, "url": "https://patchwork.libcamera.org/api/1.1/patches/16734/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16734/", "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": "<20220722151635.239221-2-fsylvestre@baylibre.com>", "date": "2022-07-22T15:16:31", "name": "[libcamera-devel,v2,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/16734/mbox/", "series": [ { "id": 3319, "url": "https://patchwork.libcamera.org/api/1.1/series/3319/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3319", "date": "2022-07-22T15:16:30", "name": "Add GSL, LSC and DPCC tuning support for rkisp1", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3319/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16734/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16734/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 AE590BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 22 Jul 2022 15:16:47 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 675BE63318;\n\tFri, 22 Jul 2022 17:16:47 +0200 (CEST)", "from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com\n\t[IPv6:2a00:1450:4864:20::42a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CD7C863313\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Jul 2022 17:16:44 +0200 (CEST)", "by mail-wr1-x42a.google.com with SMTP id h9so6979995wrm.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Jul 2022 08:16:44 -0700 (PDT)", "from BL087.. ([2a01:e34:eea9:e630:e9da:4076:6aa:6cd2])\n\tby smtp.gmail.com with ESMTPSA id\n\tb1-20020a5d4d81000000b0021e4fd8e10bsm4871557wru.11.2022.07.22.08.16.43\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 22 Jul 2022 08:16:43 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658503007;\n\tbh=pMzNI7g/tFbiOPklsa+5EIbxGf0di9GSiColgaj2RLM=;\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=2SRKZKqeSL7aDQTk94mb8Fy/3Pfu048wC9+ehaGDVA3W3wuFoarczA8pG5mcvK6sx\n\tJA9hKOj8EhkDO0D7hmpsRu2Qv9AoIrjSuXRNR3CcuqD964ItlgQuHPcJW6HiOKGss8\n\tq4kR7j3qoGsXZg4bbRj5zT5Lxrp5ceZOlfB6u1joS+fX8yNPK6ylJACKvZFFY3A6OS\n\tPaGR7sdemHxHuPOKVTZHmsaZHqNruiQBse7CDnLyjxBYytqiEdP1EQvrdozWnIQzoC\n\tVVK8fXiJvDkQ09RnfRE9Se9FpdcIz+YGXJZjI8OTKeZqxHk2gWEgyTePW7qgsuJwOX\n\tv4fWfF7OgR1iA==", "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=m7hUmiaKzanMb2eUzI916OaV1LitMalvbU40wiWSryc=;\n\tb=gX0b9CIzCIJV45UAC8oEJpx39U6HMCh1mTKKpfvs+fJjsULfE8JKLLSW9yzfz1FleI\n\toauBy7kbxLMxlHoAqBo+r5KJyqNKN2D/6yVxAW1zZ82GTyip4F2yK2P2Jp4SGawknCsP\n\tSiYNuMnb0SQqWFIm3YTh6+7Q1rcqGZXuYYrIDI5VR/nhci6z1a4BmJjL5IVC7Qs7e4IG\n\tIHtLQEPdlLzW/hE2rnaVRYNMotSKvst9HFYw2ix1aAtYytlFaUFMoU+a3Vk4nC91z6Lp\n\tThJK8eVORRGii4ykUp5UyIv981AZGMYuscG7g8IY4crhuLdhlJIQGNVen+MH6qUfkT1M\n\t3jYg==" ], "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=\"gX0b9CIz\"; \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=m7hUmiaKzanMb2eUzI916OaV1LitMalvbU40wiWSryc=;\n\tb=OrFdEdRUysDLiI9iMLBl7IlHnkKZahGUndHv1sZYbU7U8YW9pn37IJGQEQQd2tN2di\n\tM4F6UaRgLtSybnJeN1jrqOfUB7P71+r4mHEnlIUkn6s4fDPPWDbDls58q0pvd16y0URs\n\tSp0dVG3CaDEOSEPeYAkmIMXuT2WM6KxcIVBvgwwXQXMRyrXheesb1FOhlGKEKudM3/mf\n\tyk170jnwHmQoEADpkULc8AQiE7YrrU79SX0+Z1qktPvXo1FjZFaxDhSpKWWuwhYutzvE\n\tXhmFyY7dPBG2RVuTIc8xjQsyctbqqBl3KmVH4JAE8pcSKjHWc0iHrBl143Rj5HhnSeZa\n\tchSA==", "X-Gm-Message-State": "AJIora/HlT6mYxgRCGHyz92xCIOa5IpKsuG75tGEnIDXKQsMVuOimzIk\n\tpvaR6TS33r2c/M1Zt3l8CVzns50Wf2iYoQH+", "X-Google-Smtp-Source": "AGRyM1uMTXsACDZrKMEsZHAxrFkRR610oGE/gyz72LdNVr0x0QLvhkERpQCsPH8TIgoE0I/HonxjPg==", "X-Received": "by 2002:a5d:5847:0:b0:21d:b75e:12d0 with SMTP id\n\ti7-20020a5d5847000000b0021db75e12d0mr294379wrf.208.1658503004069; \n\tFri, 22 Jul 2022 08:16:44 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 22 Jul 2022 17:16:31 +0200", "Message-Id": "<20220722151635.239221-2-fsylvestre@baylibre.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220722151635.239221-1-fsylvestre@baylibre.com>", "References": "<20220722151635.239221-1-fsylvestre@baylibre.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 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>\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", "v2", "1/5" ] }