{"id":26463,"url":"https://patchwork.libcamera.org/api/1.1/patches/26463/?format=json","web_url":"https://patchwork.libcamera.org/patch/26463/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","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-24-laurent.pinchart@ideasonboard.com>","date":"2026-04-07T15:34:08","name":"[v2,23/42] libcamera: value_node: Add mutable children accessors","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"fc1c0bc6699ae8ebefd5c450ad6e7c4767dc08ee","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26463/mbox/","series":[{"id":5873,"url":"https://patchwork.libcamera.org/api/1.1/series/5873/?format=json","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/26463/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26463/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 4804EC3307\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Apr 2026 15:35:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 98EFE62E0E;\n\tTue,  7 Apr 2026 17:35:05 +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 4686F62DD4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Apr 2026 17:35:00 +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 AAC2278E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Apr 2026 17:33:32 +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=\"M6DXkGC4\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1775576012;\n\tbh=JqgS7hrHDzNYfjW9RzfFDyQAkTr40KmcOSJvIKKsprQ=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=M6DXkGC42+zdKVZ2Aqo8rcoh03dfM1iaZ/P7rQBajiDLxnJ/X9CsdOZgdKgq7hekQ\n\t1sar4kxi4tUDQJyew0IMQFOIfeBtmIi9HBJU0DhSGcHyiiejhgSg6GSAYtJ4a/BBIQ\n\tr0EjiEB9NQua/8foMXNIcXAz6fIefjoR5fN0ANbQ=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v2 23/42] libcamera: value_node: Add mutable children\n\taccessors","Date":"Tue,  7 Apr 2026 18:34:08 +0300","Message-ID":"<20260407153427.1825999-24-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-Type":"text/plain; charset=UTF-8","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 two at() functions that return mutable pointer to child nodes, based\non an index for lists and a key for dictionaries.\n\nThe API differs from const children accessors that use operator[] and\nreturn a reference in order to allow better error handling: while the\nconst accessors return a reference to a global instance of an empty\nValueNode when the requested child doesn't exist, a mutable accessor\ncan't do the same without allowing modifying the empty global instance.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\nChanges since v1:\n\n- Improve documentation\n- Fix typo in commit message\n---\n include/libcamera/internal/value_node.h |  2 ++\n src/libcamera/value_node.cpp            | 42 +++++++++++++++++++++++++\n 2 files changed, 44 insertions(+)","diff":"diff --git a/include/libcamera/internal/value_node.h b/include/libcamera/internal/value_node.h\nindex 3bdb537e9eab..d237b2c1e0d6 100644\n--- a/include/libcamera/internal/value_node.h\n+++ b/include/libcamera/internal/value_node.h\n@@ -230,9 +230,11 @@ public:\n \tConstDictAdapter asDict() const { return ConstDictAdapter{ list_ }; }\n \tConstListAdapter asList() const { return ConstListAdapter{ list_ }; }\n \n+\tValueNode *at(std::size_t index);\n \tconst ValueNode &operator[](std::size_t index) const;\n \n \tbool contains(std::string_view key) const;\n+\tValueNode *at(std::string_view key);\n \tconst ValueNode &operator[](std::string_view key) const;\n \n \tValueNode *add(std::unique_ptr<ValueNode> &&child);\ndiff --git a/src/libcamera/value_node.cpp b/src/libcamera/value_node.cpp\nindex 5aef72cd29a4..4c3a5e4d381d 100644\n--- a/src/libcamera/value_node.cpp\n+++ b/src/libcamera/value_node.cpp\n@@ -384,6 +384,25 @@ template struct ValueNode::Accessor<std::vector<std::string>>;\n  * \\return An adapter of unspecified type compatible with range-based for loops\n  */\n \n+/**\n+ * \\brief Retrieve the element from list ValueNode by index\n+ * \\param[in] index The element index\n+ *\n+ * This function retrieves an element of the ValueNode. Only ValueNode\n+ * instances of List type associate elements with an index, calling this\n+ * function on other types of instances or with an invalid index returns a null\n+ * pointer.\n+ *\n+ * \\return The ValueNode corresponding to \\a index\n+ */\n+ValueNode *ValueNode::at(std::size_t index)\n+{\n+\tif (type_ != Type::List || index >= size())\n+\t\treturn nullptr;\n+\n+\treturn list_[index].value.get();\n+}\n+\n /**\n  * \\brief Retrieve the element from list ValueNode by index\n  * \\param[in] index The element index\n@@ -419,6 +438,29 @@ bool ValueNode::contains(std::string_view key) const\n \treturn dictionary_.find(key) != dictionary_.end();\n }\n \n+/**\n+ * \\brief Retrieve a member by key from the dictionary\n+ * \\param[in] key The element key\n+ *\n+ * This function retrieves a member of a ValueNode by \\a key. Only ValueNode\n+ * instances of Dictionary type associate elements with keys, calling this\n+ * function on other types of instances or with a nonexistent key returns a null\n+ * pointer.\n+ *\n+ * \\return The ValueNode corresponding to the \\a key member\n+ */\n+ValueNode *ValueNode::at(std::string_view key)\n+{\n+\tif (type_ != Type::Dictionary)\n+\t\treturn nullptr;\n+\n+\tauto iter = dictionary_.find(key);\n+\tif (iter == dictionary_.end())\n+\t\treturn nullptr;\n+\n+\treturn iter->second;\n+}\n+\n /**\n  * \\brief Retrieve a member by key from the dictionary\n  * \\param[in] key The element key\n","prefixes":["v2","23/42"]}