{"id":26539,"url":"https://patchwork.libcamera.org/api/patches/26539/?format=json","web_url":"https://patchwork.libcamera.org/patch/26539/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20260423230059.3180987-18-laurent.pinchart@ideasonboard.com>","date":"2026-04-23T23:00:39","name":"[v3,17/37] libcamera: value_node: Add mutable children accessors","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"fc1c0bc6699ae8ebefd5c450ad6e7c4767dc08ee","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26539/mbox/","series":[{"id":5883,"url":"https://patchwork.libcamera.org/api/series/5883/?format=json","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/26539/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26539/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 18570BDCB5\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Apr 2026 23:01:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 82A5262FB8;\n\tFri, 24 Apr 2026 01:01:34 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F69962FA0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Apr 2026 01:01:25 +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 9E9C6C75\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Apr 2026 00:59:45 +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=\"rEI3mo7y\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1776985185;\n\tbh=eaiIlizXOeEKWM9qFFxqa7THLDeDOPecz1G2qG/TvNE=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=rEI3mo7ynt6UMkYtwqWVQZNIqeT5q+LxAJJ+h6iezDh0xOJxWjMlHUwQZGl0bqbit\n\t7t0hRdgW5jY6hr+DljY2xYx0zc74TjDtO+OiFnfo8WCqKibp39TGtQzYsutLW6CmvO\n\t14sCdodM7xEV6w4V6PYQtbggeVvlh+tyE/bp/Rhs=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v3 17/37] libcamera: value_node: Add mutable children\n\taccessors","Date":"Fri, 24 Apr 2026 02:00:39 +0300","Message-ID":"<20260423230059.3180987-18-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-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>\nReviewed-by: Isaac Scott <isaac.scott@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 b51d2f4b610b..da68a74c5e14 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 e2dd455d3f1e..fbf9ac470359 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":["v3","17/37"]}