Patch Detail
Show a patch.
GET /api/patches/26529/?format=api
{ "id": 26529, "url": "https://patchwork.libcamera.org/api/patches/26529/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26529/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20260423230059.3180987-8-laurent.pinchart@ideasonboard.com>", "date": "2026-04-23T23:00:29", "name": "[v3,07/37] libcamera: yaml_parser: Add functions to add children", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "55ef15f1bd8101e5f8e242aae8fe8f802a386794", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/26529/mbox/", "series": [ { "id": 5883, "url": "https://patchwork.libcamera.org/api/series/5883/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5883", "date": "2026-04-23T23:00:22", "name": "libcamera: Global configuration file improvements", "version": 3, "mbox": "https://patchwork.libcamera.org/series/5883/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26529/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26529/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 4ABA1BDCB5\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Apr 2026 23:01:17 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 463A962F72;\n\tFri, 24 Apr 2026 01:01:16 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7DD9862F6E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Apr 2026 01:01:10 +0200 (CEST)", "from killaraus.ideasonboard.com\n\t(2001-14ba-703d-e500--2a1.rev.dnainternet.fi\n\t[IPv6:2001:14ba:703d:e500::2a1])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F2E02802\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Apr 2026 00:59:30 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"VAT97Ofa\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1776985171;\n\tbh=8Dvn0nleUiwPSWalrMfXsahKemTcaEBSCwQKPDOQBbY=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=VAT97Ofa4TafhyiUZj60p+nP3LnrruxbPuZCAJ2ruVSZbN0UKEwjYjrr3VDiamAfZ\n\tgDEP7rk4WRQbaISS+EWTZFLj+oOWGExuJ31z+xKStfqqUop7KwZOaV3ArrGiF6DMpP\n\tQytRp2pKtVTnATaiBuSysQFMHuX2lCgsrW1oH3UE=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v3 07/37] libcamera: yaml_parser: Add functions to add\n\tchildren", "Date": "Fri, 24 Apr 2026 02:00:29 +0300", "Message-ID": "<20260423230059.3180987-8-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.53.0", "In-Reply-To": "<20260423230059.3180987-1-laurent.pinchart@ideasonboard.com>", "References": "<20260423230059.3180987-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add YamlObject::add() functions to add children to a list or dictionary\nobject. This will be used by the YamlParserContext to replace direct\naccess to YamlObject member variables to decouple the two classes.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\n---\nChanges since v2:\n\n- Fix typo in documentation\n\nChanges since v1:\n\n- Avoid std::map lookup before insertion in YamlObject::add()\n- Don't move child node if add fails\n---\n include/libcamera/internal/yaml_parser.h | 5 ++-\n src/libcamera/yaml_parser.cpp | 55 ++++++++++++++++++++++++\n 2 files changed, 59 insertions(+), 1 deletion(-)", "diff": "diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\nindex 0666762308ac..3be61c503c88 100644\n--- a/include/libcamera/internal/yaml_parser.h\n+++ b/include/libcamera/internal/yaml_parser.h\n@@ -28,7 +28,7 @@ class YamlObject\n {\n private:\n \tstruct Value {\n-\t\tValue(std::string &&k, std::unique_ptr<YamlObject> &&v)\n+\t\tValue(std::string k, std::unique_ptr<YamlObject> &&v)\n \t\t\t: key(std::move(k)), value(std::move(v))\n \t\t{\n \t\t}\n@@ -197,6 +197,9 @@ public:\n \tbool contains(std::string_view key) const;\n \tconst YamlObject &operator[](std::string_view key) const;\n \n+\tYamlObject *add(std::unique_ptr<YamlObject> &&child);\n+\tYamlObject *add(std::string key, std::unique_ptr<YamlObject> &&child);\n+\n private:\n \tLIBCAMERA_DISABLE_COPY_AND_MOVE(YamlObject)\n \ndiff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\nindex 8c84f560ff0f..5b2e743ee41a 100644\n--- a/src/libcamera/yaml_parser.cpp\n+++ b/src/libcamera/yaml_parser.cpp\n@@ -436,6 +436,61 @@ const YamlObject &YamlObject::operator[](std::string_view key) const\n \treturn *iter->second;\n }\n \n+/**\n+ * \\brief Add a child object to a list\n+ * \\param[in] child The child object\n+ *\n+ * Append the \\a child object as the last element of this object's children\n+ * list. This object must be empty, in which case it is converted to the\n+ * Type::List type, or be a list. Otherwise, the function returns a nullptr and\n+ * the \\a child is not modified.\n+ *\n+ * \\return A pointer to the child object if successfully added, nullptr\n+ * otherwise\n+ */\n+YamlObject *YamlObject::add(std::unique_ptr<YamlObject> &&child)\n+{\n+\tif (type_ == Type::Empty)\n+\t\ttype_ = Type::List;\n+\n+\tif (type_ != Type::List)\n+\t\treturn nullptr;\n+\n+\tValue &elem = list_.emplace_back(std::string{}, std::move(child));\n+\treturn elem.value.get();\n+}\n+\n+/**\n+ * \\brief Add a child object to a dictionary\n+ * \\param[in] key The dictionary key\n+ * \\param[in] child The child object\n+ *\n+ * Add the \\a child object with the given \\a key to this object's children. This\n+ * object must be empty, in which case it is converted to the Type::Dictionary\n+ * type, or be a dictionary. Otherwise, the function returns a nullptr and the\n+ * \\a child is not modified.\n+ *\n+ * Keys are unique. If a child with the same \\a key already exists, the function\n+ * returns a nullptr and the \\a child is not modified.\n+ *\n+ * \\return A pointer to the child object if successfully added, nullptr\n+ * otherwise\n+ */\n+YamlObject *YamlObject::add(std::string key, std::unique_ptr<YamlObject> &&child)\n+{\n+\tif (type_ == Type::Empty)\n+\t\ttype_ = Type::Dictionary;\n+\n+\tif (type_ != Type::Dictionary)\n+\t\treturn nullptr;\n+\n+\tauto [it, inserted] = dictionary_.try_emplace(std::move(key), child.get());\n+\tif (!inserted)\n+\t\treturn nullptr;\n+\n+\treturn list_.emplace_back(it->first, std::move(child)).value.get();\n+}\n+\n #ifndef __DOXYGEN__\n \n class YamlParserContext\n", "prefixes": [ "v3", "07/37" ] }