Patch Detail
Show a patch.
GET /api/patches/26453/?format=api
{ "id": 26453, "url": "https://patchwork.libcamera.org/api/patches/26453/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26453/", "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": "<20260407153427.1825999-14-laurent.pinchart@ideasonboard.com>", "date": "2026-04-07T15:33:58", "name": "[v2,13/42] libcamera: yaml_parser: Add functions to add children", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "83b210e123efe70507ca5d87f658992872fd39ef", "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/26453/mbox/", "series": [ { "id": 5873, "url": "https://patchwork.libcamera.org/api/series/5873/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5873", "date": "2026-04-07T15:33:45", "name": "libcamera: Global configuration file improvements", "version": 2, "mbox": "https://patchwork.libcamera.org/series/5873/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26453/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26453/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 51E46C32F5\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 7 Apr 2026 15:34:50 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D590962DD3;\n\tTue, 7 Apr 2026 17:34:49 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0FFFD62DC4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 7 Apr 2026 17:34:46 +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 UTF8SMTPSA id 80F5B98A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 7 Apr 2026 17:33:18 +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=\"bmZSvL0Y\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1775575998;\n\tbh=ELMgsAtzXAignrpDM/vf18ndkoQBVXdeUmlrI9Ss+Gk=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=bmZSvL0YqGZMBLRA5NIT30rJOvN1P+OQANdE+Ym4OCL7/AHNHLZENhEfclt19AWvi\n\t1Ipz8boz6NjeIY3b2LkScwV6g5BFpRns06HNfVk2mIQrx90Mk8dDiZ/RIBdAmOqGbH\n\t2aMNc/fhd5VbbfV6EXPjVxTyvRM/dNTtSc6o7BaI=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v2 13/42] libcamera: yaml_parser: Add functions to add\n\tchildren", "Date": "Tue, 7 Apr 2026 18:33:58 +0300", "Message-ID": "<20260407153427.1825999-14-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.52.0", "In-Reply-To": "<20260407153427.1825999-1-laurent.pinchart@ideasonboard.com>", "References": "<20260407153427.1825999-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>\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 3119ab41d89e..61088c7aed4f 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 exist, 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": [ "v2", "13/42" ] }